ahoriuch has asked for the wisdom of the Perl Monks concerning the following question:
I'm having difficulties converting binary to double precision floating point. Using an on-line calculator, here is what the number should be: 5.71713084433028663131071134273E-5 Here's the number in hex:
unpack("H16",$buffer); #Returns 3f0d f967 3344 c570
Here is the number in "d":
unpack("d",$buffer); #Returns 1.69044404965372e+235
Something is clearly wrong. Reading the unpack documentation, there is no option for "D". Is there another way I can convert this number?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Converting binary to double precision (big-endian)
by BrowserUk (Patriarch) on Feb 24, 2014 at 19:06 UTC | |
by ahoriuch (Acolyte) on Feb 24, 2014 at 21:34 UTC | |
|
Re: Converting binary to double precision
by toolic (Bishop) on Feb 24, 2014 at 18:25 UTC | |
by ahoriuch (Acolyte) on Feb 24, 2014 at 18:35 UTC | |
by toolic (Bishop) on Feb 24, 2014 at 18:37 UTC | |
by ahoriuch (Acolyte) on Feb 24, 2014 at 18:55 UTC | |
|
Re: Converting binary to double precision
by Anonymous Monk on Feb 24, 2014 at 18:42 UTC |