uhmmm... Why don't you just loop through all the bits in the value shifting it over, then checking it with a logic AND(mask 1). Add "1" to it if it's true, else "0".
Simple?
MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116
Lets say you have the value ten, and in binary that is represented as "00001010." Mask(AND operator) all the bits before the first one and the truth is now false, place a zero to the array; shift the original value right once and mask again, this time the truth is true, add an "1"; repeat.
Well the array would look like "01010000" if you did that, there's an easy fix or just reverse it. If that's to much for you, can you use C++'s bitset class container?
MosaicFuneral
Posting Virtuoso
1,691 posts since Nov 2008
Reputation Points: 888
Solved Threads: 116