Python 3.0 new integer division

Matimus mccredie at gmail.com
Tue Apr 8 12:32:24 EDT 2008


On Apr 8, 9:13 am, "Hutch" <A... at MCHSI.COM> wrote:
> We now have a float result when two integers are divided in the same mannor
> as 2.4 or 2.5.
> I can handle that and use the Floor division but a simple question.
>
> Why in the world would you round down the last presented digit to a 6
> instead of just leaving it along as an 8.
> For some reason rounding down for a float in Python does not seem correct.
>
> IDLE 3.0a4
>
> >>> 12345678901234567890123456789012345678901234567890/345
>
> 3.5784576525317586e+46
>
> >>> 12345678901234567890123456789012345678901234567890//345
>
> 35784576525317588087314367504383610663481839327
>                                 ^
>                                 ^|
> 35784576525317586000000000000000000000000000000  == 3.5784576525317586e+46

This just has to do with the way floating point numbers are
represented in memory. More information:
http://docs.python.org/tut/node16.html

Matt



More information about the Python-list mailing list