mailThe name clash of 'float.py' with the builtin function 'float()' and bits vs. bytes.


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on November 11, 2006 - 05:51:
I've just noticed an important name clash with 'float.py'.  The module
name clashes with the inbuilt function 'float()'.  Hence if you import
float rather than it's functions, you will no longer have access to
the 'float()' function.  Gary, do you think the module should be
renamed to something like 'ieee_754.py'?  Or maybe 'fp_754.py'?  Any
other ideas?  I would guess that to eventually get it distributed with
Python as a standard module (possibly replacing 'fpconst.py' if that
ever gets into Python), the name clash would need to be resolved.

I was also wondering if there was an advantage working with bytes and
hexadecimal rather than plain bits (as a string or array of 1 and 0's)
in 'float.py'?  Is this necessary because of the 'struct' module
functions 'pack()' and 'unpack()'?  Does it help with the endianness
issues?

Another question I have is in the docstring of the SIGNBIT byte, you
say the sign bit in bytes is '0b00000001'.  Did you mean '0b10000000'?
Or are you representing position 63 of the double precision float bit
pattern on the far right?  Oh and one last thing, does 'packed[::-1]'
properly reverse the byte order?  For example:

   packed = pack('d', 1.0e-25)  ->  '\xd9}\xda\xf5\xd0\xf2\xbe:',
   packed[::-1]  ->  ':\xb3\xf2\xd0\xf5\xda}\xd9'.

I have no idea what the ':' or '}' mean here, but should the string be
'\xbe:\xf2\xd0\xf5\xda\xd9}'?  Would using the first characters '<'
and '>' be a better way of supporting little and big endianness?

Cheers,

Edward



Related Messages


Powered by MHonArc, Updated Mon Nov 13 15:20:36 2006