Negativ nearest interger?

joni joni8135 at gmail.com
Thu Sep 22 13:16:34 CEST 2011


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)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> 7.0/3  #fist to show floiting-point calculation
2.3333333333333335
>>> -7.0/3
-2.3333333333333335
>>> -7/-3 #Rounding to nearest interger.
2
>>> 7/3
2
>>> 7/-3  #Now to the problem with interger rounding with negative anwser.
-3
>>> -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?




More information about the Python-list mailing list