The Haskell RealFloat
typeclass has a function called isIEEE
which, according to the documentation, gives 'True if the argument is an IEEE floating point number' (and, one would imagine, False otherwise).
But here's the implementation of isIEEE
for Float
:
instance RealFloat Float where
...
isIEEE _ = True
And here's the implementation for Double
:
instance RealFloat Double where
...
isIEEE _ = True
If isIEEE
is always unconditionally True
, why use it? Why have it in the Prelude at all?
As leftaroundabout and Koterpillar mentioned in the comments, it is possible to define your own instances of RealFloat. These custom-made float types do not necessarily have to follow the IEEE standards.
instance RealFloat MyFloat where
isIEEE _ = False
...
Additionally, if your floating-point type isn't IEEE, you are allowed to have all RealFloat predicates return False:
(...) The functions isNaN, isInfinite, isDenormalized, isNegativeZero, and isIEEE all support numbers represented using the IEEE standard. For non-IEEE floating point numbers, these may all return false.
Haskell 98 Report, 6.4.6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With