On Apr 8, 2010, at 6:53 PM, Daniel Fischer wrote:

> Am Freitag 09 April 2010 02:51:23 schrieb Gregory Crosswhite:
> 
> Yes, but 1/0 isn't a NaN:
> 
> Prelude> isNaN (1.0/0.0)
> False
> Prelude> isNaN (0.0/0.0)
> True
> Prelude> 1.0/0.0
> Infinity
> Prelude> 0.0/0.0
> NaN
> Prelude> (0.0/0.0) == (0.0/0.0)
> False

Curse you for employing the dirty trick of employing easily verifiable facts to 
prove me wrong!  :-)

> Yup. But using (==) on floating point numbers is dangerous even without 
> NaNs. Warning against that can be beneficial.

Fair enough.

On a tangental note, I've considered coding up a package with an "AlmostEq" 
typeclass that allows one to test for approximate equality.  The problem is 
that different situations call for different tolerances so there is no standard 
"approximate equal" operator that would work for everyone, but there might be a 
tolerance that is "good enough" for most situations where it would be needed 
(such as using QuickCheck to test that two different floating-point functions 
that are supposed to return the same answer actually do so) to make it 
worthwhile to have a standard package for this around for the sake of 
convenience.

Anyone have any thoughts on this?

Cheers,
Greg

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to