Logo

Programming-Idioms

History of Idiom 81 > diff from v60 to v61

Edit summary for version 61 by programming-idioms.org:
[Dart] +DemoURL

Version 60

2020-08-10, 23:03:10

Version 61

2020-11-05, 15:19:44

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
var y = x.round();
Comments bubble
This rounds ties "away from zero", though.
Comments bubble
This rounds ties "away from zero", though.
Demo URL
https://dartpad.dev/32508506d144cbed2e5a90a6f5b06d20