Logo

Programming-Idioms

History of Idiom 81 > diff from v5 to v6

Edit summary for version 6 by :

Version 5

2015-09-04, 10:52:28

Version 6

2015-09-05, 14:01:42

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).

Imports
import std.math: round;
Code
int y = cast(int) x.round;