Data.Floating.Classes
Description
Generic classes for floating point types. The interface is loosely based off of the C math library.
- data FPClassification
- = FPInfinite
- | FPNaN
- | FPNormal
- | FPSubNormal
- | FPZero
- class (Fractional a, Poset a) => Roundable a where
- class Fractional a => Floating a where
- class Floating a => RealFloat a where
- fma :: a -> a -> a -> a
- copysign :: a -> a -> a
- nextafter :: a -> a -> a
- atan2 :: a -> a -> a
- fmod :: a -> a -> a
- frem :: a -> a -> a
- hypot :: a -> a -> a
- cbrt :: a -> a
- exp2 :: a -> a
- expm1 :: a -> a
- log10 :: a -> a
- log1p :: a -> a
- log2 :: a -> a
- logb :: a -> a
- erf :: a -> a
- erfc :: a -> a
- gamma :: a -> a
- lgamma :: a -> a
- rint :: a -> a
- nearbyint :: a -> a
- infinity :: a
- nan :: a
- pi :: a
- class (Roundable a, RealFloat a) => PrimFloat a where
- classify :: a -> FPClassification
Documentation
data FPClassification Source
Classification of floating point values.
Constructors
FPInfinite | |
FPNaN | |
FPNormal | |
FPSubNormal | |
FPZero |
class (Fractional a, Poset a) => Roundable a whereSource
Class for types which can be rounded to integers. The rounding functions in the Prelude are inadequate for floating point because they shoehorn their results into an integral type.
Minimal complete definition: toIntegral
and round
.
Methods
toIntegral :: Integral b => a -> Maybe bSource
Discards the fractional component from a value. Results in Nothing
if the result cannot be represented as an integer, such as if the input
is infinite or NaN.
class Fractional a => Floating a whereSource
Class for floating point types (real or complex-valued).
Minimal complete definition: everything.
Methods
class Floating a => RealFloat a whereSource
Class for real-valued floating point types.
Minimal complete definition: all except pi
, infinity
and nan
.
Methods
Fused multiply-add.
copysign x y
computes a value with the magnitude of x
but the sign
of y
.
nextafter :: a -> a -> aSource
nextafter x y
computes the next representable value after x
in the
direction of y
.
atan2 y x
computes the principal value of the arctangent of y/x
.
The signs of the input determine the quadrant of the result.
fmod x y
computes x - n*y
, where n
is the integral quotient of
x/y
, rounded towards zero.
frem x y
computes x - n*y
, where n
is the integral quotient of
x/y
, rounded to the nearest integer, with halfway values rounded to
even.
Euclidean distance function without undue overflow.
Cube root.
Base-2 exponential function.
Computes exp x - 1
without undue cancellation.
Base-10 logarithm function.
Computes log (x + 1)
without undue cancellation.
Base-2 logarithm function.
Extracts the exponent of a floating point value. If the value is subnormal, the result is as if the value were normalized.
Error function.
Complementary error function.
Gamma function.
Log gamma function.
Round to the nearest integer according to the current rounding
direction. The default rounding direction is towards the nearest
integer with halfway values rounded to even. If the resulting value
differs from the input, the Inexact
exception is raised.
Same as rint
, except that the Inexact
exception is not raised.