Logo

Programming-Idioms

History of Idiom 81 > diff from v19 to v20

Edit summary for version 20 by :
New Pascal implementation by user [Bart]

Version 19

2016-01-03, 13:35:02

Version 20

2016-01-15, 15:42: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
var
  y: integer;
  x: double;
begin
  y := round(x);
end.