On Tue, Jun 5, 2012 at 9:12 AM, Warren Harris <warrensomeb...@gmail.com> wrote:
> which helps in many cases, but for some the parsing seems bi-stable, 
> alternating between two imprecise double values and causing the test to fail.

You want to perform your test as

    d1 - d2 < epsilon

where epsilon is derived from the relative error you're willing to
accept (e.g. 0.01% error.) You can't use an absolute epsilon because
if you pick e.g. epsilon = 0.00001 but your input are also very small,
you'll end up accepting a big relative error. Comparing floating
points values for equality is asking for trouble.

> I was wondering if anyone could suggest a better work-around for this 
> problem, or explain why Attoparsec's double parser can't be isomorphic to 
> haskell's. Thanks,

I think attoparsec uses a slightly less exact but much much faster
double parser. I believe it's described in the attoparsec haddock docs
somewhere.

-- Johan

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to