True, but it is one long division overall, not one per digit.
I just thought of a better algorithm.
(a) Find nr. digits, i.e. smallest N s.t. base^(N+1) > number.
Let k = base^N. Can use a constant here if preferred.
(b) Do N times:
1. Subtract k repeatedly from number: count = digit.
(Or use a faster method for a constant base, such as
successive approximation).
2. Multiply number by base.
It's better than the one I proposed before (and the one Linus outlined):
no table is required, no divisions, just multiplication by the base.
But this is getting silly :-)
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/