Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (9)
As of 2017-02-28 10:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (399 votes). Check out past polls.