Extract double in binary file
Bengt Richter
bokr at oz.net
Tue Dec 2 17:17:42 EST 2003
On 2 Dec 2003 09:40:50 -0800, pascal.parent at free.fr (Pascal) wrote:
>A very big thanks to you.
>The function run perfectly (after python 2.3! installed for enumerate function)
>If you can, give me more details on the methode or the number's representation.
>
>Thanks a lot!
According to an old MASM 5.0 programmer's guide, there was a Microsoft Binary format
for encoding real numbers, both short (32 bits) and long (64 bits).
There were 3 parts:
1. Biased 8-bit exponent in the highest byte (last in the little-endian view we've been using)
It says the bias is 0x81 for short numbers and 0x401 for long, but I'm not sure where that lines up.
I just got there by experimentation.
2. Sign bit (0 for +, 1 for -) in upper bit of second highest byte.
3. All except the first set bit of the mantissa in the remaining 7 bits of the second highest byte,
and the rest of the bytes. And since the most signficant bit for non-zero numbers is 1, it
is not represented. But if if were, it would share the same bit position where the sign is
(that's why I or-ed it in there to complete the actual mantissa).
MASM also supported a 10-byte format similar to IEEE. I didn't see anything in that section
on NaNs and INFs.
HTH
Regards,
Bengt Richter
More information about the Python-list
mailing list