Hey, that reminds me of a cool little script I wrote. I had an assignment where I had
to convert lots of numbers from decimal to binary, and each converstion had to be accompanied by
tediously high amounts of working out. Being lazy, out came Perl and out came a nice script which
printed out the working for each question. Woohoo! It was something like:
20 / 2 = 10 rem 0
10 / 2 = 5 rem 0
5 / 2 = 2 rem 1
2 / 2 = 1 rem 0
1 / 2 = 0 rem 1
Therefore 20 in binary is
10100
| [reply] |
The functions pack and unpack can be of great help here, if you don't want to do a loop:
my $number = "12345";
my $bin_number = unpack("B32", pack("N", $number));
print "$number in binary is $bin_number\n";
Use a regex to get rid of leading zeroes. | [reply] [d/l] |
Can you post the code? I'd like to run it and see what kinda alien werds I can incorporate into my daily speech. =). TTFN & Shalom.
-PipTigger | [reply] |
What class is that for?!? | [reply] |
THREAD NECROMANCY
The class was a high school seminar on communications, taught by the principal; it was six freakin years ago. I can't find the script, small wonder -- where all my work from before July of 2000 went is a damn good question.
I'm now a perl hacker in and around new york city, and I've just reactivated my permonks account. Seeing how you all respond to necromancy OF EPIC PROPORTIONS.
| [reply] |
Ho ho! So you think we aren't paying attention? A dusty old thread like this?
We see everywhere! We know everything! We never sleep!
Welcome back, hope you enjoy the place.
• another intruder with the mooring in the heart of the Perl
| [reply] |