Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How to pack and unpack 16 bit decimal with leading zero

by RichardK (Parson)
on Jul 27, 2015 at 10:56 UTC ( [id://1136439]=note: print w/replies, xml ) Need Help??


in reply to [SOLVED] How to pack and unpack 16 bit decimal with leading zero

Just use printf.

perl -E 'printf "%016b",123;' 0000000001111011

You didn't say what you're trying to achieve and it looks like an XY problem, but you seem to be trying to recreate fixed point maths. Maybe reading up on that may help?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-20 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found