Another Proposal re- Integer Division

Rainer Deyke root at rainerdeyke.com
Tue Jul 24 11:24:37 EDT 2001


"Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in message
news:mailman.995980002.564.python-list at python.org...
> Given:  Portable integer division code between 2.2 and 2.4
>         will be ugly, i.e.:
>
>             floor(n/2)

That would be incorrect.

>>> a = 11111111111111111111111111111111111111111111111111111111111111111l
>>> a / 2
5555555555555555555555555555555555555555555555555555555555555555L
>>> floor(a / 2.0)
5.5555555555555555e+063
>>> long(floor(a / 2.0))
5555555555555555511613257015757436156819784538568358631420461056L

There is no excuse for using floating points, ever.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list