RFC on floating point output work
Fri Oct 3 03:05:00 GMT 2003
I've done some more work on the floatconv library. I addressed the
issues that Richard pointed out and cleaned up the Bigint class some
I've also done somewhat fairer timing comparisons to see where things
For relatively small numbers, for example < 1e14, the dtoa conversion
here is MUCH faster than sprintf. When dtoa uses the multiple
precision code, it is significantly slower than sprintf.
The optimal performance I currently get is by using dtoa's
optimizations, but switching back to sprintf for anything else.
I've done two timing tests. These were done on an Athlon xp2200. The
first generates 500,000 random doubles and prints them to a buffer:
The second prints numbers from 1 to 500,000 to a buffer:
It seems like there's not a lot of value in bringing in the dtoa
multiple precision code, since it slows things down. One thing we do
get from the dtoa code is a prediction of how large a buffer we need,
which is useful.
I was hoping the results would point to completely removing sprintf
code, but that doesn't seem to be the case. However, the native
double optimization is worth bringing in and we can get rid of the
snprintf code, since dtoa will tell us how big a buffer is required.
The current version of floatconv.cc is at
As before, comments are appreciated.
More information about the Libstdc++