hmm... hmm... umm... I said this algorithm will work for all bases of the form 2^n and base 10. But according to you, this algorithm will work if the base is of the form 2*n. I'll just clarify right after commenting. Hold on...
UPDATE
apologies, my assumption was wrong. This algorithm will work, i.e. produce correct output, if the base is of the form 2*n.