IEEE specification requires the sign of the remainder is the same as numerator in case remainder is zero.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
mod is not bound to the IEEE 754 remainder operation. It binds the C fmod operation. You're looking for the remainder operation.
However, fmod has the same requirement: "The fmod functions return the value x − ny, for some integer n such that, if y is nonzero, the result has the same sign as x and magnitude less than the magnitude of y."