Logo

Programming-Idioms

History of Idiom 81 > diff from v18 to v19

Edit summary for version 19 by :
[Go] Proper import

Version 18

2016-01-03, 13:31:38

Version 19

2016-01-03, 13:35:02

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