pub enum Integral {
TowardZero,
Upward,
Downward,
NearestTiesAway,
}Expand description
Which integer a value is taken to, for Float::to_integral.
The four are C’s trunc, ceil, floor and round, and they are the four of that family
whose answer does not depend on the rounding mode the program is running under. rint and
nearbyint are the two that do, and there is no variant for them here: a compiler that folded
one would be answering for a mode it cannot know, which is why gcc will not fold one either and
says so by refusing static double x = __builtin_rint(2.5); as not a constant.
Variants§
TowardZero
Toward zero, which drops the fraction and keeps the sign. C’s trunc.
Upward
Toward positive infinity. C’s ceil.
Downward
Toward negative infinity. C’s floor.
NearestTiesAway
To the nearest, with a half going away from zero rather than to even. C’s round, and the
one place in C where a tie does not go to even.