laziness, impatience, and hubris | |
PerlMonks |
Re^3: Decimal to Binary using Bitwise and operatorby RMGir (Prior) |
on Jul 16, 2009 at 11:49 UTC ( [id://780666]=note: print w/replies, xml ) | Need Help?? |
That's pretty good!
All you're missing now is a way to string this information together. If $decimal & 128 is true, then you want a "1", otherwise you want a "0". Then you append the same thing for 64, 32, 16, .... At the end, you'll have your answer. After that, what's left is looking at your code and seeing if you can clean it up, remove redundancies, convert sequences of similar instructions to loops with the differences moved into constant arrays, things like that. Oh, and don't forget tests! The nice thing about having such a limited input domain (only 256 possible inputs) is that you can actually test your program for all of them and make sure you got it right. Mike
In Section
Seekers of Perl Wisdom
|
|