Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Encode and decode binary-coded decimals

by jryan (Vicar)
on Oct 08, 2002 at 16:59 UTC ( #203693=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -le 'print join " ", map {ord pack "H2", $_} shift =~ /../g' 396
    
  2. or download this
    perl -le 'print unpack "H*", pack "C*", @ARGV' 0011 1001 0110
    
  3. or download this
    # encode
    perl -e 'print sprintf("%04b ",$_) for shift =~ /\d/g' decimal
    
    #decode
    perl -e '$p=1; map{$l+=oct("0b$_")*$p;$p*=10} reverse @ARGV; print $l'
    + bcddigit1 bcddigit2 etc
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2015-07-06 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls