Float package:base-prelude

Single-precision floating point numbers. It is desirable that this type be at least equal in range and precision to the IEEE single-precision type.
Trigonometric and hyperbolic functions and related functions. The Haskell Report defines no laws for Floating. However, (+), (*) and exp are customarily expected to define an exponential field and have the following properties:
  • exp (a + b) = exp a * exp b
  • exp (fromInteger 0) = fromInteger 1
a constant function, returning the number of digits of floatRadix in the significand
a constant function, returning the radix of the representation (often 2)
a constant function, returning the lowest and highest values the exponent may assume
floatToDigits takes a base and a non-negative RealFloat number, and returns a list of digits and an exponent. In particular, if x>=0, and
floatToDigits base x = ([d1,d2,...,dn], e)
then
  1. n >= 1
  2. x = 0.d1d2...dn * (base**e)
  3. 0 <= di <= base-1
Efficient, machine-independent access to the components of a floating-point number.
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 x yields (m,n), then x is equal in value to m*b^^n, where b is the floating-point radix, and furthermore, either m and n are both zero or else b^(d-1) <= abs m < b^d, where d is the value of floatDigits x. In particular, decodeFloat 0 = (0,0). If the type contains a negative zero, also decodeFloat (-0.0) = (0,0). The result of decodeFloat x is unspecified if either of isNaN x or isInfinite x is True.
encodeFloat performs the inverse of decodeFloat in the sense that for finite x with the exception of -0.0, uncurry encodeFloat (decodeFloat x) = x. encodeFloat m n is one of the two closest representable floating-point numbers to m*b^^n (or ±Infinity if overflow occurs); usually the closer, but if m contains too many bits, the result may be rounded in the wrong direction.
Constructs the Float type
Reads an unsigned RealFrac value, expressed in decimal scientific notation.
multiplies a floating-point number by an integer power of the radix
Show a signed RealFloat value using scientific (exponential) notation (e.g. 2.45e2, 1.5e-3). In the call showEFloat digs val, if digs is Nothing, the value is shown to full precision; if digs is Just d, then at most d digits after the decimal point are shown.
Show a signed RealFloat value using standard decimal notation (e.g. 245000, 0.0015). In the call showFFloat digs val, if digs is Nothing, the value is shown to full precision; if digs is Just d, then at most d digits after the decimal point are shown.
Show a signed RealFloat value using standard decimal notation (e.g. 245000, 0.0015). This behaves as showFFloat, except that a decimal point is always guaranteed, even if not needed.
Show a signed RealFloat value to full precision using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise.
Show a signed RealFloat value using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise. In the call showGFloat digs val, if digs is Nothing, the value is shown to full precision; if digs is Just d, then at most d digits after the decimal point are shown.
Show a signed RealFloat value using standard decimal notation for arguments whose absolute value lies between 0.1 and 9,999,999, and scientific notation otherwise. This behaves as showFFloat, except that a decimal point is always guaranteed, even if not needed.
Show a floating-point value in the hexadecimal format, similar to the %a specifier in C's printf.
>>> showHFloat (212.21 :: Double) ""
"0x1.a86b851eb851fp7"

>>> showHFloat (-12.76 :: Float) ""
"-0x1.9851ecp3"

>>> showHFloat (-0 :: Double) ""
"-0x0p+0"