原文来自:http://www.trapexit.org/Floating_Point_Rounding
In erlang, u need to round a floating-point number to an integer.
floor(X) when X < 0 ->
T = trunc(X),case X - T == 0 of
true -> T;
false -> T - 1
end;
floor(X) ->
trunc(X).
ceiling(X) when X < 0 ->
trunc(X);
ceiling(X) ->
T = trunc(X),
case X - T == 0 of
true -> T;
false -> T + 1
end.