
Xavier Ho wrote:
Personally, I've always liked Python's behaviour in this regard: for the few times that I've needed an 'x % y' operation that works with both positive and negative x, more often than not x-y*floor(x/y) turns out to be what I need. I've lost count of the number times I've had to write something awkward like:
/* adjust for the exponent; first reduce it modulo _PyHASH_BITS */ e = e >= 0 ? e % _PyHASH_BITS : _PyHASH_BITS-1-((-1-e) % _PyHASH_BITS);
in C.
Wow. I would never write code like that, but you got a fair point.
For Python, Mark (and others) write code like that so the rest of us don't have to ;) Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia ---------------------------------------------------------------