andreas1234567 has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
I have difficulties converting data on a binary format to decimal numbers related to this node. I suspect the number are encoded using a float. I'm able to see what the results should be using a third-party tool.
The number should perform as follows:
- 3F F0 00 00 00 00 00 00 should yield 1.
- 40 59 00 00 00 00 00 00 should yield 100.
- 41 33 1A 9D 00 00 00 00 should yield 1251997.
A hexdump of the source file is available on my pad (relax it's only 192 bytes).
Update: It seems like this does the trick (updated as shown by Anonymous Monk):
Update: pfaut++ and Fletch++ for good advice to stubborn monk.# read number: 8 bytes, return decimal value sub getnumber { my $buffer = undef; my $num = read($FH, $buffer, 8); return unpack 'd*', reverse $buffer; }
--
Andreas
Andreas
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Binary to decimal conversion
by Anonymous Monk on Dec 11, 2007 at 10:19 UTC | |
by andreas1234567 (Vicar) on Dec 11, 2007 at 10:34 UTC | |
by pfaut (Priest) on Dec 11, 2007 at 11:48 UTC | |
by andreas1234567 (Vicar) on Dec 11, 2007 at 11:57 UTC | |
by Fletch (Bishop) on Dec 11, 2007 at 13:43 UTC | |
| |
Re: Binary to decimal conversion
by Anonymous Monk on Dec 11, 2007 at 09:24 UTC | |
by andreas1234567 (Vicar) on Dec 11, 2007 at 09:45 UTC | |
by Anonymous Monk on Dec 11, 2007 at 10:06 UTC |
Back to
Seekers of Perl Wisdom