roundToZero

Sets round() to behave like trunc().

After the call, floor() and ceil() are not anymore reliable.

const(int)
roundToZero
@trusted pure nothrow
(
)

Return Value

Type: const(int)

The previous rounding mode, which can be restored with setIzRoundingMode().

Examples

1 auto sav = roundToNearest;
2 assert(round(0.4) == 0);
3 auto dnc0 = roundToZero;
4 assert(round(0.8) == 0);
5 assert(round(-0.8) == 0);
6 auto dnc1 = roundToNegative;
7 assert(round(1.8) == 1);
8 assert(round(-0.8) == -1);
9 auto dnc2 = roundToPositive;
10 assert(round(1.8) == 2);
11 assert(round(-0.8) == 0);
12 setIzRoundingMode(sav);

Meta