Re: C function for returning number of digits?



In article <0pacfn4lih.fsf@xxxxxxxxxxxxxxxxxx>,
Niklas Norrthon <do-not-use@xxxxxxxxxxx> wrote:

>And how do you fix this when the next version of your compiler ships
>(which use 333 bit longs)?

>A solution using snprintf could work, but io functions are quite complex
>so I'd not be surprised if the log10 was faster. Personally I'd go for
>either a counting loop, or a binary lookup table, depending on how
>critical speed, and time for implementation are.

If one is assuming that the next generation compiler might have 333 bit
longs (and of course the DS9000 has 666 bit longs whenever it feels like
it ;-) ), then one would need to initialize the binary lookup table
at runtime. The code to do that without risking overflow (UB) is
probably not so long, but is likely a bit interesting.
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
.