altfloat-0.3.1: Alternative floating point support for GHC.



Generic classes for floating point types. The interface is loosely based off of the C math library.



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.


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.

ceiling :: a -> aSource

floor :: a -> aSource

truncate :: a -> aSource

round :: a -> aSource

class Fractional a => Floating a whereSource

Class for floating point types (real or complex-valued).

Minimal complete definition: everything.


(**) :: a -> a -> aSource

sqrt :: a -> aSource

acos :: a -> aSource

asin :: a -> aSource

atan :: a -> aSource

cos :: a -> aSource

sin :: a -> aSource

tan :: a -> aSource

acosh :: a -> aSource

asinh :: a -> aSource

atanh :: a -> aSource

cosh :: a -> aSource

sinh :: a -> aSource

tanh :: a -> aSource

exp :: a -> aSource

log :: a -> aSource

class Floating a => RealFloat a whereSource

Class for real-valued floating point types.

Minimal complete definition: all except pi, infinity and nan.


fma :: a -> a -> a -> aSource

Fused multiply-add.

copysign :: a -> a -> aSource

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 :: a -> a -> aSource

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 :: a -> a -> aSource

fmod x y computes x - n*y, where n is the integral quotient of x/y, rounded towards zero.

frem :: a -> a -> aSource

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.

hypot :: a -> a -> aSource

Euclidean distance function without undue overflow.

cbrt :: a -> aSource

Cube root.

exp2 :: a -> aSource

Base-2 exponential function.

expm1 :: a -> aSource

Computes exp x - 1 without undue cancellation.

log10 :: a -> aSource

Base-10 logarithm function.

log1p :: a -> aSource

Computes log (x + 1) without undue cancellation.

log2 :: a -> aSource

Base-2 logarithm function.

logb :: a -> aSource

Extracts the exponent of a floating point value. If the value is subnormal, the result is as if the value were normalized.

erf :: a -> aSource

Error function.

erfc :: a -> aSource

Complementary error function.

gamma :: a -> aSource

Gamma function.

lgamma :: a -> aSource

Log gamma function.

rint :: a -> aSource

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.

nearbyint :: a -> aSource

Same as rint, except that the Inexact exception is not raised.

infinity :: aSource

nan :: aSource

pi :: aSource

class (Roundable a, RealFloat a) => PrimFloat a whereSource

Class for the basic floating point types.