6fb57595249f6409c81d44b53dafc8101dd34b16
2 - Copyright (C) 2009-2010 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.
9 -- | Top level module for alternative floating point support.
10 module Data
.Floating
(
12 module Data
.Floating
.Types
.Core
,
16 import Prelude
hiding (RealFloat
(..), RealFrac
(..), Double, Float)
17 import Data
.Floating
.Types
.Core
hiding (Double, Float, FloatConvert
)
18 import Data
.Floating
.Instances
19 import Data
.Floating
.Types
.Double
20 import Data
.Floating
.Types
.Float
21 import Data
.Floating
.Environment
22 import Data
.Floating
.Types
.CMath
26 isInfinite :: PrimFloat a
=> a
-> Bool
27 isInfinite = (== FPInfinite
) . classify
29 isNaN :: PrimFloat a
=> a
-> Bool
30 isNaN = (== FPNaN
) . classify
32 isNormal
:: PrimFloat a
=> a
-> Bool
33 isNormal
= (== FPNormal
) . classify
35 isSubNormal
:: PrimFloat a
=> a
-> Bool
36 isSubNormal
= (== FPSubNormal
) . classify
38 isFinite
:: PrimFloat a
=> a
-> Bool
39 isFinite
= not . liftM2 (||
) isInfinite isNaN
41 isNegativeZero :: PrimFloat a
=> a
-> Bool
42 isNegativeZero = liftM2 (&&) ((== FPZero
) . classify
) ((== (-1)) . signum)
44 -- | @fquotRem x y@ computes the remainder and integral quotient upon division
45 -- of x by y. The result is (x-n*y, n), where n is the value x/y rounded to
46 -- the nearest integer.
47 fquotRem
:: RealFloat a
=> a
-> a
-> (a
, a
)
48 fquotRem x y
= (frem x y
, nearbyint
(x
/y
))