[Haskell-cafe] Re: Defaulting to Rational [was: Number overflow]

ok ok at cs.otago.ac.nz
Thu Jul 12 21:59:27 EDT 2007


On 13 Jul 2007, at 2:58 am, apfelmus wrote:
> What I wanted to do is to capture common patterns
>
>   x - y >=3D epsilon
>   abs (x - y) <=3D epsilon
>
> for comparing floating point numbers in nice functions
>
>   x >> y =3D x - y >=3D epsilon
>   x =C5  y =3D abs (x - y) <=3D epsilon

See Knuth, The Art of Computer Programming,
Volume 2, Semi-Numerical algorithms,
for a suitable set of predicates and axioms they satisfy.
However, they depend on epsilon (or APL's []CT, comparison
tolerance).  I once implemented the four predicates Knuth
discussed in Quintus Prolog (library(fuzzy)).  As far as I
know, nobody ever used it.  I had plans for making the
code faster if anybody cared, but no-one did.

I suspect these functions would be no more useful in
Haskell:  anyone who knew enough to use them would know enough
not to.




More information about the Haskell-Cafe mailing list