"normalizing" a value

random832 at fastmail.us random832 at fastmail.us
Thu Jul 2 04:23:05 CEST 2015

On Wed, Jul 1, 2015, at 21:49, bvdp wrote:
> Interesting that negative values translate properly. That's an
> non-intuitive result to me. Guess I should have studied that math stuff
> harder way back when!

There are multiple interpretations of the operation, and not all
languages behave the same way as Python does with negative operands.
Python is the odd one out when one considers C/C++, C#, and Java which
all behave a different way.

In general, almost all languages behave in a way so that given q, r = a
// b, a % b; q * b + r == a. However, this simply changes the question
to how division results involving negative operands are rounded.

Here's an article by GvR about why python behaves the way it does:

More information about the Python-list mailing list