Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Convert binary to decimal problem

by ikegami (Patriarch)
on Apr 06, 2008 at 16:41 UTC ( [id://678658]=note: print w/replies, xml ) Need Help??


in reply to Convert binary to decimal problem

0x007102 = 100.000000 0x00350C = 500.000000

0x0C3500 = 0x027100 * 5, so the byte order is reversed.

0x027100 = 160000, so maybe packed = 1600 * unpacked?

0x300515 / 1600 =? 860.99 Yes!

Solution:

my $raw = 0x300515; my $val = unpack('N', "\x00".pack('V', $raw))/1600
or
my $raw = "\x30\x05\x15"; my $val = unpack('V', "$raw\x00")/1600;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://678658]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-03-29 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found