I want if it is bigger or equal to 0 to round it to the bigger number and if it is smaller than 0 to round it to the number before. Eg: If the number is 2.5 show 3 and if the number is -2.5 show -3. How should i write this? I wrote :
let round x = if (x >= 0) then int_of_float x
else int_of_float ( x -. 1.0);;
or
let round x = if ( x>=0) then truncate (x +. 0.5)
else truncate ( x -. 0.5);;
and to both it gives me the same error :
Error: This expression has type int but an expression was expected of type
float
How should I write it?