On 06.12.2011 08:20, Walter Bright wrote:
On 12/5/2011 10:52 PM, Don wrote:
On 06.12.2011 05:15, Walter Bright wrote:
On 12/5/2011 8:10 PM, bearophile wrote:
This is not about integers but yeah, I'd like the better str<-> float
conversions of Python in D too.

Do you have any test data that they actually are better in Python (apart
from just being better specified)?

Bug 5229 is an example.

I have five papers on this topic. Most recent is the excellent:
Florian Loitsch, "Printing FP numbers quickly and accurately with
integers" (2010)

Right now, we rely on C's standard library. Often, it's deficient. We
should roll our own, like we did with the math routines, and make sure
the D standard reflects the modern thinking on it.

(Python's implementation currently uses David Gay's dtoa.c)

The Loitsch paper is very interesting, it presents a simple very fast method which works in 99.5% of cases. Then, you fall back to the simple slow method for the remaining 0.5%. The slow case is rare enough that it's not worth optimizing it.

By contrast, dtoa.c is very complicated, because its fast method only works for ~75% of cases, so there are many optimisations for special cases of the slow method.

Reply via email to