Re:Python, unlike C, has the mod operator always return a po...
by ThinBold on Thursday December 30, 2021 @03:58AM
(#29734989)
What a beautiful way to shoot yourself in the foot
Re:Python, unlike C, has the mod operator always return a po...
by olliej on Thursday December 30, 2021 @10:29PM
(#29744559)
When I first encountered it it sent me down a path of paper reading that made me sad.
Even better, because it's defined in terms of rounding, it changes according to rounding mode :D
Even more fun as the original x87 implementation preceded IEEE754 its remainder operation (fprem, because it's technically a partial remainder) used truncation rather than rounding as that's the obvious behaviour. To support the IEEE754 specification they had to add fprem1 which performs a rounding operation instead. Hurrah! :D