Problem converting IEEE 754 binary to double

Lars Rößiger lars.roessiger at d33.net
Fri Oct 28 13:20:44 CEST 2005


I solved the problem with a 100-liner (C).

lars at devbox:~$ ./hex2double 541F48DE39D02540
IEEE 754 number: 541F48DE39D02540
Big Endian: 4025D039DE481F54
decimal exponent: 3

hex  dec  bin
0x5    5  0 1 0 1
0xD   13  1 1 0 1
0x0    0  0 0 0 0
0x3    3  0 0 1 1
0x9    9  1 0 0 1
0xD   13  1 1 0 1
0xE   14  1 1 1 0
0x4    4  0 1 0 0
0x8    8  1 0 0 0
0x1    1  0 0 0 1
0xF   15  1 1 1 1
0x5    5  0 1 0 1
0x4    4  0 1 0 0

binary value: 0101110100000011100111011110010010000001111101010100
double value: 10.906616210937500 (precision 15 decimals)

Cheers
--Lars

Lars Rößiger schrieb:
> Hello!
> 
> I'm trying to convert this binary to a double:
> 
> 0xEA82B0091FD02540
> 
> This binary is little endian, so I switched the bytes and are using this
> binary instead:
> 
> 0x4025D01F09B082EA
> 
> I played around with mpf_set_str() and mpf_get_d() without any success.
> GMP never returns the correct corresponding double (which would be
> around 10.9064868).
> 
> Can anyone point me into the right direction?
> 
> Thank you,
> Lars
> 


More information about the gmp-discuss mailing list