1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
@safe unittest { import std.math.hardware; import std.math.rounding : lrint; FloatingPointControl fpctrl; fpctrl.rounding = FloatingPointControl.roundDown; assert(lrint(1.5) == 1.0); fpctrl.rounding = FloatingPointControl.roundUp; assert(lrint(1.4) == 2.0); fpctrl.rounding = FloatingPointControl.roundToNearest; assert(lrint(1.5) == 2.0); }