440,035 Members | 1,984 Online
Need help? Post your question and get tips & solutions from a community of 440,035 IT Pros & Developers. It's quick & easy.

# Python 3.0 new integer division

 P: n/a 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 >>123456789012345678901234567890123456789012345678 90/345 3.5784576525317586e+46 >>123456789012345678901234567890123456789012345678 90//345 35784576525317588087314367504383610663481839327 ^ ^| 35784576525317586000000000000000000000000000000 == 3.5784576525317586e+46 Apr 8 '08 #1
6 Replies

 P: n/a On Apr 8, 9:13 am, "Hutch" 1234567890123456789012345678901234567890123456789 0/345 3.5784576525317586e+46 >1234567890123456789012345678901234567890123456789 0//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 Apr 8 '08 #2

 P: n/a "Matimus" We now have a float result when two integers are divided in the samemannoras 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 6instead of just leaving it along as an 8.For some reason rounding down for a float in Python does not seemcorrect.IDLE 3.0a4 >>123456789012345678901234567890123456789012345678 90/345 3.5784576525317586e+46 >>123456789012345678901234567890123456789012345678 90//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 Apr 8 '08 #3

 P: n/a On Apr 8, 2:25*pm, Grzegorz Słodkowicz Isn't Decimal a BCD implementation? Yep, you are right and I am wrong. http://www.python.org/dev/peps/pep-0...y-not-rational Apr 8 '08 #4

 P: n/a On Apr 8, 6:01 pm, Jonathan Gardner wrote: On Apr 8, 2:25 pm, Grzegorz Słodkowicz

 P: n/a On Apr 9, 8:35*pm, Mark Dickinson

 P: n/a On Apr 9, 3:57*pm, Arnaud Delobelle

### This discussion thread is closed

Replies have been disabled for this discussion.