Well, perhaps it doesn't make sense ;-) But I'll give it a try:
I first wrote " a % n >= 0 for all a and n", because that's what I want. Then I realized that that's not true, it's negative if n < 0, but that's a case I don't care much about.
I think of the a % n operation as a way to implement arithmetic in Z_n, integers modulo n, were elements are represented uniquely as integers in the range 0, ..., n-1. There's no problem making sure that n is always positive. It's more important to handle negative a:s, because I'd like all of
(a + b) % n, (a - b) % n and (a*b) % n
to have values in the range 0 ... n-1. It's particularly important if the inputs a, b are in that same range, but the requirement that (a-c) % n >= 0 is enough to make the round-towards-zero convention look bad.
/ Niels Möller ()
Previous text:
2003-01-15 13:49: Subject: Re: signed integer division
Maybe the "b varies a lot more than b" statement in (1.) needs a litte clarification though. It doesn't make any sense to me.
/ Marcus Comstedt (ACROSS) (Hail Ilpalazzo!)