Menu

Commit [r2801]  Maximize  Restore  History

Two functions for converting a string bit pattern to a float and a number of IEEE-754 constants.

The fucntions 'bitpatternToFloat()' and 'bitpatternToInt()' have been added to 'float.py'. The
first converts a 64 bit IEEE-754 bit pattern in the form of a string into a 64 bit Python float.
The second converts an arbitrary bit pattern into its integer representation. By looping over each
8 characters of the string (1 byte), 'bitpatternToFloat()' calls 'bitpatternToInt()' to create an
array of integers. Then 'packBytesAsPyFloat()' is called to convert the byte array into the float.
These two functions convert between big and little endian when necessary.

By passing big-endian 64 bit patterns to the 'bitpatternToFloat()' function, the following IEEE-754
constants are defined:
PosZero: 0000000000000000000000000000000000000000000000000000000000000000
NegZero: 1000000000000000000000000000000000000000000000000000000000000000
PosEpsilonDenorm: 0000000000000000000000000000000000000000000000000000000000000001
NegEpsilonDenorm: 1000000000000000000000000000000000000000000000000000000000000001
PosEpsilonNorm: 0000000000010000000000000000000000000000000000000000000000000001
NegEpsilonNorm: 1000000000010000000000000000000000000000000000000000000000000001
PosMax: 0111111111101111111111111111111111111111111111111111111111111111
NegMin: 1111111111101111111111111111111111111111111111111111111111111111
PosInf: 0111111111110000000000000000000000000000000000000000000000000000
NegInf: 1111111111110000000000000000000000000000000000000000000000000000
PosNaN_A: 0111111111110000000000000000000000000000001000000000000000000000
NegNaN_A: 1111111111110000000000000000000000000000001000000000000000000000
PosNaN_B: 0111111111110000000000000000011111111111111111111110000000000000
NegNaN_B: 1111111111110000000000000000011111111111111111111110000000000000
PosNaN_C: 0111111111110101010101010101010101010101010101010101010101010101
NegNaN_C: 1111111111110101010101010101010101010101010101010101010101010101
PosNaN = PosNaN_C
NegNaN = NegNaN_C

bugman 2006-11-11

changed /branches/test_suite/float.py
/branches/test_suite/float.py Diff Switch to side-by-side view
Loading...
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.