4 ms·
Yes, in fact that's the point I'm trying to focus on but never made explicit. Thanks.
by wyldfire 10y ago
Yes, in fact that's the point I'm trying to focus on but never made explicit. Thanks.
- tzs 10y agoInteger division rounding toward negative infinity makes it so that for integers a, b, with b > 0, then if a%b is defined as a - b * (a/b), you will always have 0 <= a%b < b. Integer division rounding toward zero makes that not so. a%b for negative a, positive b, will be <= 0. On the other hand, rounding toward negative infinity means that (-a)/b != -(a/b), when b does not divide a. Rounding toward zero makes (-a)/b = -(a/b). I think most mathematicians would rather have 0 <= a%b < b than (-a)/b = -(a/b) if they can't have both.
- danbruc 10y agoEric Lippert, a former C# compiler developer, has a good blog post [1] discussing the reasoning and the difference between modulus and remainder. [1] https://blogs.msdn.microsoft.com/ericlippert/2011/12/05/whats-the-difference-remainder-vs-modulus/ https://blogs.msdn.microsoft.com/ericlippert/2011/12/05/what...