Logo

Programming-Idioms

History of Idiom 81 > diff from v29 to v30

Edit summary for version 30 by NobbZ:
New Elixir implementation by user [NobbZ]

Version 29

2016-08-11, 20:36:00

Version 30

2016-09-14, 08:32:37

Idiom #81 Round floating point number to integer

Declare integer y and initialize it with the rounded value of floating point number x .
Ties (when the fractional part of x is exactly .5) must be rounded up (to positive infinity).

Idiom #81 Round floating point number to integer

Declare integer y and initialize it with the rounded value of floating point number x .
Ties (when the fractional part of x is exactly .5) must be rounded up (to positive infinity).

Code
y = Float.round x
Doc URL
http://elixir-lang.org/docs/stable/elixir/Float.html#round/2