Efficient, machine-independent access to the components of a floating-point number.
Methods
floatRadix :: a -> Integera constant function, returning the radix of the representation (often
2)floatDigits :: a -> Inta constant function, returning the number of digits of floatRadix in the significand
floatRange :: a -> (Int, Int)a constant function, returning the lowest and highest values the exponent may assume
decodeFloat :: a -> (Integer, Int)The function decodeFloat applied to a real floating-point number returns the significand expressed as an Integer and an appropriately scaled exponent (an Int). If
decodeFloat xyields(m,n), thenxis equal in value tom*b^^n, wherebis the floating-point radix, and furthermore, eithermandnare both zero or elseb^(d-1) <= abs m < b^d, wheredis the value offloatDigits x. In particular,decodeFloat 0 = (0,0). If the type contains a negative zero, alsodecodeFloat (-0.0) = (0,0). The result ofdecodeFloat xis unspecified if either ofisNaN xorisInfinite xis True.encodeFloat :: Integer -> Int -> aencodeFloat performs the inverse of decodeFloat in the sense that for finite
xwith the exception of-0.0,uncurry encodeFloat (decodeFloat x) = x.encodeFloat m nis one of the two closest representable floating-point numbers tom*b^^n(or±Infinityif overflow occurs); usually the closer, but ifmcontains too many bits, the result may be rounded in the wrong direction.exponent :: a -> Intexponent corresponds to the second component of decodeFloat.
exponent 0 = 0and for finite nonzerox,exponent x = snd (decodeFloat x) + floatDigits x. Ifxis a finite floating-point number, it is equal in value tosignificand x * b ^^ exponent x, wherebis the floating-point radix. The behaviour is unspecified on infinite orNaNvalues.significand :: a -> aThe first component of decodeFloat, scaled to lie in the open interval (
-1,1), either0.0or of absolute value>= 1/b, wherebis the floating-point radix. The behaviour is unspecified on infinite orNaNvalues.scaleFloat :: Int -> a -> amultiplies a floating-point number by an integer power of the radix
isNaN :: a -> BoolTrue if the argument is an IEEE "not-a-number" (NaN) value
isInfinite :: a -> BoolTrue if the argument is an IEEE infinity or negative infinity
isDenormalized :: a -> BoolTrue if the argument is too small to be represented in normalized format
isNegativeZero :: a -> BoolTrue if the argument is an IEEE negative zero
isIEEE :: a -> BoolTrue if the argument is an IEEE floating point number
atan2 :: a -> a -> aa version of arctangent taking two real floating-point arguments. For real floating
xandy,atan2 y xcomputes the angle (from the positive x-axis) of the vector from the origin to the point(x,y).atan2 y xreturns a value in the range [-pi,pi]. It follows the Common Lisp semantics for the origin when signed zeroes are supported.atan2 y 1, withyin a type that is RealFloat, should return the same value asatan y. A default definition of atan2 is provided, but implementors can provide a more accurate implementation.
Instances9RealFloat, …
RealFloat CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRealFloat CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesRealFloat DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.FloatRealFloat FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.FloatRealFloat a => RealFloat (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.IdentityRealFloat a => RealFloat (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.OrdRealFloat a => RealFloat (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstRealFloat a => RealFloat (Tagged s a)Defined in tagged-0.8.9 · Data.TaggedRealFloat (f (g a)) => RealFloat (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose