joni writes: > Have a simple question in the Integer calculator in Python 2.65 and > also 2.7.. > > The consol showing: > > Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) ... > >>> -7/3 > -3 > >>> > > -3 are more wrong than -2. Negativ number seems not to round to > nearest interger, but the integer UNDER the anwser!! Or? > > Why?
It simply does not round to the nearest integer. It floors. This has nicer mathematical properties. In particular, it allows the remainder (notated as "per cent") operation (n % m) to return a number that differs from n by a multiple of m ("is congruent to n modulo m"). These two operations go together. -- http://mail.python.org/mailman/listinfo/python-list