I hadn't heard the name "double dabble" before. But it's a good method that can be easily extended to all sorts of radix conversions, including mixed radix (for example, converting a number of seconds into weeks, days, hours, minutes, seconds).
The basic idea: you have a number in one representation (here it's binary) and you want to convert it into another (here it's decimal). Start with the result initialised to 0. Repeatedly halve the source while you double the result. Every time you get a remainder from the halving, add it to the result.
For this particular case, that'll look something like
int units = 0;
int tens = 0;
int hundreds = 0;
while ( n > 0 ) {
units = 2*units;
tens = 2*tens;
if ( units > 9 ) {
units = units-10;
tens = tens+1;
}
if ( tens > 9 ) {
tens = tens-10;
hundreds = hundreds+1;
}
if ( n%2 == 1 )
{
units = units + 1;
}
n = n >> 1;
}
The proper double dabble algorithm is a bit trickier: instead of the simple decimal doubling that I've got, it keeps two digits in each byte, and adds 3 to any half-byte that's greater than 4 before shifting it. Here, we want to end up with the digits in separate variables, so I've just gone with the simple method.
Of course, with only two digits in your display, you can delete the bits dealing with the hundreds digit.
There's another trick that can sometimes be useful for calculating mods (it isn't here, since we need the result of the division as well, but I have encountered situations where it has helped). Suppose the binary representation of our number is abcdefg. That is, n = 64a + 32b + 16c + 8d + 4e + 2f + g. We want n%10. The rules of modular arithmetic mean that n%10 = (4a + 2b + 6c + 8d + 4e + 2f + g)%10 (I've just dropped the higher digits from each coefficient). That gives us something with a much smaller range that can be calculated with a few shifts and adds.
4a + 2b + 6c + 8d + 4e + 2f + g won't be the final answer, because it can be up to 27. But needs at most 2 subtractions to get it back to 0-9, instead of the 9 that repeated subtraction needs. That gives us
c = n&0x10;
m = (n&0x60)>>4 + c>>2 + c>>3 + n&0x0f;
while ( m > 9 ) {
m = m-10;
}
As I said, it doesn't help this problem, as we need the result of the division as well.
If your processor has a divide instruction, there's a chance it gives the remainder as well. In that case, you can always say
int units = n%10;
int tens = n/10;
and hope the compiler does the right thing.