Logo

Programming-Idioms

History of Idiom 81 > diff from v27 to v28

Edit summary for version 28 by Roboticus:
New Perl implementation by user [Roboticus]

Version 27

2016-03-04, 21:50:36

Version 28

2016-04-21, 11:03: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).

Code
my $y = int($x + 1/2);