floating: Add Roundable instance for Integral a => Ratio a.
[altfloat.git] / Data / Floating.hs
blob9a918ce2c8be8a77ec77c38a671ff8f84b6e6792
1 {-
2 - Copyright (C) 2009 Nick Bowler.
4 - License BSD2: 2-clause BSD license. See LICENSE for full terms.
5 - This is free software: you are free to change and redistribute it.
6 - There is NO WARRANTY, to the extent permitted by law.
7 -}
9 -- | Top level module for alternative floating point support.
10 module Data.Floating (
11 Double, Float,
12 module Data.Floating.Classes,
13 module Data.Floating,
14 toFloating
15 ) where
17 import Prelude hiding (RealFloat(..), Double, Float)
18 import Data.Floating.Classes
19 import Data.Floating.Instances
20 import Data.Floating.Double
21 import Data.Floating.Types
23 import Control.Monad
25 isInfinite :: RealFloat a => a -> Bool
26 isInfinite = (== FPInfinite) . classify
28 isNaN :: RealFloat a => a -> Bool
29 isNaN = (== FPNaN) . classify
31 isNormal :: RealFloat a => a -> Bool
32 isNormal = (== FPNormal) . classify
34 isSubNormal :: RealFloat a => a -> Bool
35 isSubNormal = (== FPSubNormal) . classify
37 isFinite :: RealFloat a => a -> Bool
38 isFinite = not . liftM2 (||) isInfinite isNaN
40 isNegativeZero :: RealFloat a => a -> Bool
41 isNegativeZero = liftM2 (&&) ((== FPZero) . classify) ((== (-1)) . signum)