Logo

Programming-Idioms

History of Idiom 81 > diff from v10 to v11

Edit summary for version 11 by :

Version 10

2015-09-14, 19:18:37

Version 11

2015-09-17, 06:05: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
var
  y: integer;
  x: single = -1.8;
begin
  y := round(x);
end;
Demo URL
https://ideone.com/8bcrah