Python 3.0 new integer division

Hutch ABH at MCHSI.COM
Tue Apr 8 19:19:47 CEST 2008


"Matimus" <mccredie at gmail.com> wrote in message 
news:b6eafdd4-dbf8-4269-962f-531126bb10c0 at s33g2000pri.googlegroups.com...
> 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

Was thinking IBM decimal when I asked the question --should have remembered 
detail of floats.
Thanks
Hutch 





More information about the Python-list mailing list