Re: Current implementation of exp() is faulty.
- Posted by CChris <christian.cuvier at agricult?re.gouv.?r> May 21, 2008
- 770 views
Matt Lewis wrote: > > Jason Gade wrote: > > > > Here's an excerpt from Matt's scientific.e documentation: > > > <snip> > > Yes. Also, it's only currently used for scientific notation encountered. > It should be fairly easy to make it parse all floating point, though this > would slow things down a little. Not sure where the sweet spot would > be (i.e., when do we lose precision in the current "naive" algorithm). > > Matt Precision is lost when you add roundoff errors together. If, when parsing, you add 16 numbers of the form n.0E-p, none of them is exactly representable, so you get 16 times the maximum error, on bad days. I have coded an alternative which performs arithmetic on the digits of the string being parsed, so as to never combine inexact results. It supports an exact mode (givve this many bits of precision) and an auto-round mode (give as much precision as one can get with the available digits). I'll benchmark it against scientific.e - it's probably slower and more accurate - and post the findings. A few other things to do these days... CChris