[erlang-questions] Floor Function?
Fri Mar 13 19:17:56 CET 2009
There is in implementation of ceil in mochiweb's mochinum module,
floor is also trivial to write (especially given ceil as a template)
but mochiweb doesn't include it.
%% @spec int_ceil(F::float()) -> integer()
%% @doc Return the ceiling of F as an integer. The ceiling is defined as
%% F when F == trunc(F);
%% trunc(F) when F < 0;
%% trunc(F) + 1 when F > 0.
T = trunc(X),
case (X - T) of
Neg when Neg < 0 -> T;
Pos when Pos > 0 -> T + 1;
_ -> T
2009/3/13 David Mercer <>:
> While I notice there are round and trunc functions for converting floats to
> integers, I could not find a floor function. I can easily roll my own, just
> wondering if I my documentation-searching skills are lacking and whether I
> am missing something. Please advise. Thank-you.
> David Mercer
> erlang-questions mailing list
More information about the erlang-questions