Float to int conversions (was: int(float(sys.maxint)) buglet)

Nick Coghlan ncoghlan at iinet.net.au
Mon Dec 6 07:12:57 EST 2004


<Sorry for the disconnected reply -I've been having news server issues, and just 
switched to the mailing list instead>

A quick check of the source code reveals that this behaviour is deliberate. 
There is apparently an issue with the corner case breaking badly (potentially 
raising an exception) on some platforms. So, Python plays it safe and converts 
the two boundary cases to Python longs instead of Python ints.

See the code for the gory details (the relevant function is 'float_int'):
http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Objects/floatobject.c?rev=2.134&view=markup

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list