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.
In reply to Re^3: Decimal to Binary using Bitwise and operator
by RMGir
in thread Decimal to Binary using Bitwise and operator
by AchyuthaRao
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |