Logo

Programming-Idioms

History of Idiom 81 > diff from v34 to v35

Edit summary for version 35 by programming-idioms.org:
[Elixir] +DemoURL. +Warning

Version 34

2016-11-27, 14:58:20

Version 35

2016-11-30, 22:50:20

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
Code
y = Float.round x
Comments bubble
Note that negative ties are not rounded up.
Doc URL
http://elixir-lang.org/docs/stable/elixir/Float.html#round/2
Doc URL
http://elixir-lang.org/docs/stable/elixir/Float.html#round/2
Demo URL
http://play.elixirbyexample.com/s/ca0c80f667