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
In reply to Re: One-liner ascii/bin
by jj808
in thread One-liner ascii/bin
by Rolf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |