Reading a non-standard floating point format

Peter Hansen peter at
Sat Apr 26 00:55:57 CEST 2003

Fidtz wrote:
> The closest thing I have to a definition from the AlphaBasic programming
> manual: The reason for this is that floating point numbers occupy six
> bytes of storage. Of the 48 bits in use for each 6-byte variable, the
> high order bit is the sign of the mantissa. The next 8 bits represent
> the signed exponent in excess-128 notation, giving a range of
> approximately 2.9*10^-39 through 1.7*10^38. The remaining 39 bits
> contain the mantissa, which is normalized with an implied high-order bit
> of one. This gives an effective 40-bit mantissa which results in an
> accuracy of 11 significant digits.
> I had a go this afternoon and managed to read the sign and something
> approximating the exponent, though I will have to test the edge
> conditions carefully :)

Note that this is a *perfect* case for some test-driven development,
or at least some good unit tests with hand-checked data covering all
the edge cases you can find, and some other cases.

If you didn't know, Python has a good unit test framework as a
standard module, and it's very easy to build and run tests like this.
We'd be happy to help guide you too. :-)


More information about the Python-list mailing list