Logo

Programming-Idioms

History of Idiom 81 > diff from v57 to v58

Edit summary for version 58 by programming-idioms.org:
[Dart] Typo in comments

Version 57

2020-06-20, 09:55:16

Version 58

2020-06-20, 09:55:29

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).

Variables
y,x
Variables
y,x
Code
y = x.round();
Code
y = x.round();
Comments bubble
This round ties "away from zero", though.
Comments bubble
This rounds ties "away from zero", though.