| Copyright | (c) The University of Glasgow 2002 |
|---|---|
| License | BSD-style (see the file libraries/base/LICENSE) |
| Maintainer | libraries@haskell.org |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | Trustworthy |
| Language | Haskell2010 |
Numeric
Contents
Description
Odds and ends, mostly functions for reading and showingRealFloat-like kind of values.
Arguments
| ::Real a | |
| => (a ->ShowS) | a function that can show unsigned values |
| ->Int | the precedence of the enclosing context |
| -> a | the value to show |
| ->ShowS |
Converts a possibly-negativeReal value to a string.
showIntAtBase :: (Integral a,Show a) => a -> (Int ->Char) -> a ->ShowSSource#
Shows anon-negativeIntegral number using the base specified by the first argument, and the character representation specified by the second.
showEFloat ::RealFloat a =>MaybeInt -> a ->ShowSSource#
Show a signedRealFloat value using scientific (exponential) notation (e.g.2.45e2,1.5e-3).
In the call, ifshowEFloat digs valdigs isNothing, the value is shown to full precision; ifdigs is, then at mostJust dd digits after the decimal point are shown.
showFFloat ::RealFloat a =>MaybeInt -> a ->ShowSSource#
Show a signedRealFloat value using standard decimal notation (e.g.245000,0.0015).
In the call, ifshowFFloat digs valdigs isNothing, the value is shown to full precision; ifdigs is, then at mostJust dd digits after the decimal point are shown.
showGFloat ::RealFloat a =>MaybeInt -> a ->ShowSSource#
Show a signedRealFloat value using standard decimal notation for arguments whose absolute value lies between0.1 and9,999,999, and scientific notation otherwise.
In the call, ifshowGFloat digs valdigs isNothing, the value is shown to full precision; ifdigs is, then at mostJust dd digits after the decimal point are shown.
showFFloatAlt ::RealFloat a =>MaybeInt -> a ->ShowSSource#
Show a signedRealFloat value using standard decimal notation (e.g.245000,0.0015).
This behaves asshowFFloat, except that a decimal point is always guaranteed, even if not needed.
Since: 4.7.0.0
showGFloatAlt ::RealFloat a =>MaybeInt -> a ->ShowSSource#
Show a signedRealFloat value using standard decimal notation for arguments whose absolute value lies between0.1 and9,999,999, and scientific notation otherwise.
This behaves asshowFFloat, except that a decimal point is always guaranteed, even if not needed.
Since: 4.7.0.0
showFloat ::RealFloat a => a ->ShowSSource#
Show a signedRealFloat value to full precision using standard decimal notation for arguments whose absolute value lies between0.1 and9,999,999, and scientific notation otherwise.
showHFloat ::RealFloat a => a ->ShowSSource#
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"
floatToDigits ::RealFloat a =>Integer -> a -> ([Int],Int)Source#
floatToDigits takes a base and a non-negativeRealFloat number, and returns a list of digits and an exponent. In particular, ifx>=0, and
floatToDigits base x = ([d1,d2,...,dn], e)
then
n >= 1
x = 0.d1d2...dn * (base**e)
0 <= di <= base-1
NB:readInt is the 'dual' ofshowIntAtBase, andreadDec is the `dual' ofshowInt. The inconsistent naming is a historical accident.
readSigned ::Real a =>ReadS a ->ReadS aSource#
Reads asignedReal value, given a reader for an unsigned value.
Arguments
| ::Num a | |
| => a | the base |
| -> (Char ->Bool) | a predicate distinguishing valid digits in this base |
| -> (Char ->Int) | a function converting a valid digit character to an |
| ->ReadS a |
Reads anunsignedIntegral value in an arbitrary base.
readDec :: (Eq a,Num a) =>ReadS aSource#
Read an unsigned number in decimal notation.
>>>readDec "0644"[(644,"")]
readOct :: (Eq a,Num a) =>ReadS aSource#
Read an unsigned number in octal notation.
>>>readOct "0644"[(420,"")]
readHex :: (Eq a,Num a) =>ReadS aSource#
Read an unsigned number in hexadecimal notation. Both upper or lower case letters are allowed.
>>>readHex "deadbeef"[(3735928559,"")]
readFloat ::RealFrac a =>ReadS aSource#
Reads anunsignedRealFrac value, expressed in decimal scientific notation.
classFractional a =>Floating awhereSource#
Trigonometric and hyperbolic functions and related functions.
The Haskell Report defines no laws forFloating. However, '(+)', '(*)' andexp are customarily expected to define an exponential field and have the following properties:
exp (a + b) = @exp a * exp bexp (fromInteger 0) =fromInteger 1Methods
(**) :: a -> a -> ainfixr 8Source#
computeslog1p x, but provides more precise results for small (absolute) values oflog (1 + x)x if possible.
Since: 4.9.0.0
computesexpm1 x, but provides more precise results for small (absolute) values ofexp x - 1x if possible.
Since: 4.9.0.0
Produced byHaddock version 2.20.0