Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Here's the code, minus the comments, so it appears somewhat(hopefully) clearer now that you understand what I'm trying to do.$_="10101010000011110101000101001110110010100111"; (reverse, #I need it reversed so what follows will work s/(.)(.)(.)(.)/ #get the four digits && store them $a+=2**($_-1)if$$_/ee #take two to the $_power if #$$_ exists(e.g., $1 set, $2 set,etc) for 1..4 && #do it for each digit and s/1(?=\d)// && y/0-5/a-f/) #if 2-digit answer convert #to appropriate letter for hex for split /(....)/; #do this for all 4 digits #in $_ print $a, "\n";
using g++, here's the error I get:$_="10101010000011110101000101001110110010100111"; (reverse,s/(.)(.)(.)(.)/$a+=2**($_-1)if$$_/ee for 1..4 && s/1(?=\d)// && y/0-5/a-f/) for split /(....)/; print $a, "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: bin2hex converter
by Abigail (Deacon) on Jun 10, 2001 at 21:11 UTC | |
by Anonymous Monk on Jun 10, 2001 at 23:32 UTC | |
by Abigail (Deacon) on Jun 11, 2001 at 00:12 UTC | |
by Anonymous Monk on Sep 05, 2014 at 12:52 UTC | |
|
Re: bin2hex converter
by Vynce (Friar) on Jun 11, 2001 at 00:45 UTC |