showSigned Converts a possibly-negative Real value to a string.
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27
Modulebase-4.20.2.0Haskell2010
Odds and ends, mostly functions for reading and showing
RealFloat-like kind of values.
showSigned Converts a possibly-negative Real value to a string.
Shows a non-negative Integral number using the base specified by the first argument, and the character representation specified by the second.
Show non-negative Integral numbers in base 10.
Show non-negative Integral numbers in base 2.
Show non-negative Integral numbers in base 16.
Show non-negative Integral numbers in base 8.
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 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 (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
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 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 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 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
n >= 1x = 0.d1d2...dn * (base**e)0 <= di <= base-1NB: readInt is the 'dual' of showIntAtBase, and readDec is the `dual' of showInt. The inconsistent naming is a historical accident.
Reads a signed Real value, given a reader for an unsigned value.
readInt Reads an unsigned integral value in an arbitrary base.
Read an unsigned number in binary notation.
readBin "10011"[(19,"")]
Read an unsigned number in decimal notation.
readDec "0644"[(644,"")]
Read an unsigned number in octal notation.
readOct "0644"[(420,"")]
Read an unsigned number in hexadecimal notation. Both upper or lower case letters are allowed.
readHex "deadbeef"[(3735928559,"")]
Reads an unsigned RealFrac value, expressed in decimal scientific notation.
Note that this function takes time linear in the magnitude of its input
which can scale exponentially with input size (e.g. "1e100000000" is a
very large number while having a very small textual form).
For this reason, users should take care to avoid using this function on
untrusted input. Users needing to parse floating point values
(e.g. Float) are encouraged to instead use read, which does
not suffer from this issue.
Reads a non-empty string of decimal digits.
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
pi :: aexp :: a -> alog :: a -> asqrt :: a -> a(**) :: a -> a -> ainfixr 8logBase :: a -> a -> asin :: a -> acos :: a -> atan :: a -> aasin :: a -> aacos :: a -> aatan :: a -> asinh :: a -> acosh :: a -> atanh :: a -> aasinh :: a -> aacosh :: a -> aatanh :: a -> alog1p :: a -> aexpm1 :: a -> alog1pexp :: a -> alog1mexp :: a -> aFloating CDoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesFloating CFloatDefined in ghc-internal-9.1003.0 · GHC.Internal.Foreign.C.TypesFloating DoubleDefined in ghc-internal-9.1003.0 · GHC.Internal.FloatFloating FloatDefined in ghc-internal-9.1003.0 · GHC.Internal.FloatFloating a => Floating (Identity a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.IdentityFloating a => Floating (Down a)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.OrdRealFloat a => Floating (Complex a)Defined in base-4.20.2.0 · Data.ComplexFloating a => Floating (Op a b)Defined in base-4.20.2.0 · Data.Functor.ContravariantFloating a => Floating (Const a b)Defined in ghc-internal-9.1003.0 · GHC.Internal.Data.Functor.ConstFloating (f (g a)) => Floating (Compose f g a)Defined in base-4.20.2.0 · Data.Functor.Compose