in reply to Re^2: Decimal to Binary using Bitwise and operator
in thread Decimal to Binary using Bitwise and operator
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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Decimal to Binary using Bitwise and operator
by AchyuthaRao (Initiate) on Jul 17, 2009 at 09:03 UTC | |
by Anonymous Monk on Nov 12, 2009 at 23:24 UTC | |
Re^4: Decimal to Binary using Bitwise and operator
by jhumphreys (Novice) on Oct 04, 2012 at 02:26 UTC | |
by RMGir (Prior) on Oct 04, 2012 at 11:38 UTC | |
by jhumphreys (Novice) on Oct 04, 2012 at 17:32 UTC | |
Re^4: Decimal to Binary using Bitwise and operator
by Anonymous Monk on Sep 02, 2017 at 11:00 UTC | |
by roboticus (Chancellor) on Sep 02, 2017 at 17:25 UTC |