itoa'd you so?
smorrey at gmail.com
Fri Sep 21 14:45:45 MDT 2007
Since the sprintf function is slowing down on the log10 due to
floating point arithmetic, I wonder if a further optimization could be
made by rewriting the log10 function in assembler to take advantage of
the floating point registers?
My ASM is way to rusty to attempt this right now but I think I'll go
through the IA-32 docs and check out the feasibility of doing this.
While it would be pointless for itoa (we would still need to convert
float to int), it might work nicely for an ftoa function :)
On 9/20/07, Dave Smith <dave at thesmithfam.org> wrote:
> 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;
> return ret;
> PLUG: http://plug.org, #utah on irc.freenode.net
> Unsubscribe: http://plug.org/mailman/options/plug
> Don't fear the penguin.
More information about the PLUG