base-3.0.0.0: Basic librariesContentsIndex
Numeric
Portabilityportable
Stabilityprovisional
Maintainerlibraries@haskell.org
Contents
Showing
Reading
Miscellaneous
Description
Odds and ends, mostly functions for reading and showing RealFloat-like kind of values.
Synopsis
showSigned :: Real a => (a -> ShowS) -> Int -> a -> ShowS
showIntAtBase :: Integral a => a -> (Int -> Char) -> a -> ShowS
showInt :: Integral a => a -> ShowS
showHex :: Integral a => a -> ShowS
showOct :: Integral a => a -> ShowS
showEFloat :: RealFloat a => Maybe Int -> a -> ShowS
showFFloat :: RealFloat a => Maybe Int -> a -> ShowS
showGFloat :: RealFloat a => Maybe Int -> a -> ShowS
showFloat :: RealFloat a => a -> ShowS
floatToDigits :: RealFloat a => Integer -> a -> ([Int], Int)
readSigned :: Real a => ReadS a -> ReadS a
readInt :: Num a => a -> (Char -> Bool) -> (Char -> Int) -> ReadS a
readDec :: Num a => ReadS a
readOct :: Num a => ReadS a
readHex :: Num a => ReadS a
readFloat :: RealFrac a => ReadS a
lexDigits :: ReadS String
fromRat :: RealFloat a => Rational -> a
Showing
showSigned
:: Real a
=> (a -> ShowS)a function that can show unsigned values
-> Intthe precedence of the enclosing context
-> athe value to show
-> ShowS
Converts a possibly-negative Real value to a string.
showIntAtBase :: Integral a => a -> (Int -> Char) -> a -> ShowS
Shows a non-negative Integral number using the base specified by the first argument, and the character representation specified by the second.
showInt :: Integral a => a -> ShowS
Show non-negative Integral numbers in base 10.
showHex :: Integral a => a -> ShowS
Show non-negative Integral numbers in base 16.
showOct :: Integral a => a -> ShowS
Show non-negative Integral numbers in base 8.
showEFloat :: RealFloat a => Maybe Int -> a -> ShowS

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.

showFFloat :: RealFloat a => Maybe Int -> a -> ShowS

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.

showGFloat :: RealFloat a => Maybe Int -> a -> ShowS

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.

showFloat :: RealFloat a => a -> ShowS
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.
floatToDigits :: RealFloat a => Integer -> a -> ([Int], Int)

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
Reading
NB: readInt is the 'dual' of showIntAtBase, and readDec is the `dual' of showInt. The inconsistent naming is a historical accident.
readSigned :: Real a => ReadS a -> ReadS a
Reads a signed Real value, given a reader for an unsigned value.
readInt
:: Num a
=> athe base
-> (Char -> Bool)a predicate distinguishing valid digits in this base
-> (Char -> Int)a function converting a valid digit character to an Int
-> ReadS a
Reads an unsigned Integral value in an arbitrary base.
readDec :: Num a => ReadS a
Read an unsigned number in decimal notation.
readOct :: Num a => ReadS a
Read an unsigned number in octal notation.
readHex :: Num a => ReadS a
Read an unsigned number in hexadecimal notation. Both upper or lower case letters are allowed.
readFloat :: RealFrac a => ReadS a
Reads an unsigned RealFrac value, expressed in decimal scientific notation.
lexDigits :: ReadS String
Reads a non-empty string of decimal digits.
Miscellaneous
fromRat :: RealFloat a => Rational -> a
Converts a Rational value into any type in class RealFloat.
Produced by Haddock version 0.8