Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: One-liner ascii/bin

by jj808 (Hermit)
on Nov 11, 2001 at 09:25 UTC ( [id://124643]=note: print w/replies, xml ) Need Help??


in reply to One-liner ascii/bin

My assumption was that you wanted binary to decimal conversion. If so, try these:
Binary to Decimal: perl -e 'for(split//,$ARGV[0]){$t+=$_;$t=$t<<1};$t=$t>>1;print "$t\n"' + 101010 Decimal to Binary: perl -e '$t=$ARGV[0];do{push@b,$t%2;$t=$t>>1}until($t==0);print revers +e"\n",@b' 42

Cheers,

JJ

Replies are listed 'Best First'.
Re: Re: One-liner ascii/bin
by I0 (Priest) on Nov 11, 2001 at 13:13 UTC
    perl -e 'print oct"0b$ARGV[0]","\n"' 101010
    perl -e 'printf"%b\n",@ARGV' 42

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-25 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found