Eshell V5.8.4 (abort with ^G) 1> is_float(round(1.5)). false 2> is_integer(round(1.5)). true 3> is_float(trunc(1.5)). false 4> is_integer(trunc(1.5)). true 5> round(1.5). 2 6> trunc(1.5). 1
Erlang float to integer
Today I decided to write very small article. I think it may be
interesting for programmers who came to Erlang from Java, C++ or C. From
the point of view of Erlang developer everything is very simple. You
just need to round or truncate the float and it will become an integer.
Here is an example: