[erlang-questions] Floor Function?
Bob Ippolito
bob@REDACTED
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.
int_ceil(X) ->
T = trunc(X),
case (X - T) of
Neg when Neg < 0 -> T;
Pos when Pos > 0 -> T + 1;
_ -> T
end.
2009/3/13 David Mercer <dmercer@REDACTED>:
> 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
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
More information about the erlang-questions
mailing list