[erlang-questions] casting float to integer
Håkan Stenholm
hokan.stenholm@REDACTED
Sat May 12 02:14:31 CEST 2007
Nitin Verma wrote:
> Hi All,
>
> I am looking for a function/BIF that can help me.
>
> Problem: I need a float number's floored integer. That is if:
> A = f(5/2), then A = 2 and
> A = f(1000/501), then A = 1
>
> I found 'round/1' but it just rounds-off .
>
> -- Nitin
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
see erlang.erl documentation:
-----------------------------------------------------------------------
*|trunc(Number) -> int()|*
Types:
*|Number = number()|*
Returns an integer by the truncating |Number|.
> *trunc(5.5).*
5
Allowed in guard tests.
More information about the erlang-questions
mailing list