> last $ takeWhile (\x -> 1 + x /= 1) (iterate (/2) 1)
2.220446049250313e-16

This works because of the way IEEE floating-point numbers are
represented, so it's good for the majority of machines, but it is
technically a hack, in that it depends on a representation of
floating-point numbers in some form akin to the IEEE (1.mantissa
bits)*2^(exponent).  It would be nice for those of us interested in
doing numerical work in Haskell if we could have machine epsilon
available from the language, in case we're running on a machine where
that assumption doesn't hold.  I don't know where this would belong --
the Numeric library seems mainly concerned with reading and showing
numbers, and System is more about interacting with the OS than making
statements about the properties of the underlying hardware.

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

Reply via email to