[rust-dev] Division and modulo for signed numbers

Diggory Hardy lists at dhardy.name
Thu Apr 25 07:52:08 PDT 2013

> My opinion (that nobody will follow, but I still give it) is that integers
> should not have the "/" operator at all. This was one of the bad choices of
> C (or maybe of a previous language).

Hmm, maybe, though I can imagine plenty of people being surprised at that.

What really gets me though is that % is commonly called the "mod" operator and 
yet has nothing to do with modular arithmatic (I actually wrote a blog post 
about it a few months back: [1]). If it were my choice I'd either make "x % y" 
do real modular arithmatic (possibly even throwing if y is not positive) or 
have no % operator (just mod and rem keywords).

[1]: http://diggoryhardy.wordpress.com/2013/01/08/why-division-remainder-and-modulus-are-not-the-same/


More information about the Rust-dev mailing list