How do I test if a floating point number is an integer in haskell?

floating-point, haskell, integer

Solution

isInt x = x == fromInteger (round x)

> isInt 2
True
> isInt 2.5
False

And just a reminder: always remember the almighty curse of the floating point numbers:

> isInt (0.1^2*200)
False
> 0.1^2*200
2.0000000000000004

Problem

If I have a floating point number in Haskell how do I test if it is a whole number.

Original source