Derek Davis wrote:
Why not.  I'll post my answer just since it came out faster than
sprintf.  Well, when I pass in a buffer, rather than allocating it in
the function.  Don't know about the speed comparison when allocating.
Not that this answers your question...

Yes, it turns out that using log10() is the slow point. Floating point math must be a lot slower than I thought. I wrote and used this integer-based log10 function function instead and now my code is about twice as fast as sprintf(). Yay.

int log10i( unsigned int i )
{
   int ret = 0;
   while( i )
   {
       i /= 10;
       ret++;
   }
   return ret;
}

--Dave

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to