Logo

Programming-Idioms

History of Idiom 81 > diff from v16 to v17

Edit summary for version 17 by :
[Go] Proper import

Version 16

2016-01-03, 13:22:52

Version 17

2016-01-03, 13:25:48

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 = Kernel.round(x)
Doc URL
http://elixir-lang.org/docs/v1.0/elixir/Kernel.html#round/1
Demo URL
http://play.elixirbyexample.com/s/ae07d7d1e3