Numeric (original) (raw)

Showing

showSigned Source #

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-negative [Real](Prelude.html#t:Real "Prelude") value to a string.

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

Show a signed [RealFloat](Prelude.html#t:RealFloat "Prelude") 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](Numeric.html#v:showGFloat "Numeric")` digs val, if digs is [Nothing](Data-Maybe.html#v:Nothing "Data.Maybe"), the value is shown to full precision; if digs is `[Just](Data-Maybe.html#v:Just "Data.Maybe")` d, then at most d digits after the decimal point are shown.

showGFloatAlt :: RealFloat a => Maybe Int -> a -> ShowS Source #

Show a signed [RealFloat](Prelude.html#t:RealFloat "Prelude") 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](Numeric.html#v:showFFloat "Numeric"), except that a decimal point is always guaranteed, even if not needed.

Since: base-4.7.0.0

showFloat :: RealFloat a => a -> ShowS Source #

Show a signed [RealFloat](Prelude.html#t:RealFloat "Prelude") 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.

showHFloat :: RealFloat a => a -> ShowS Source #

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"

Since: base-4.11.0.0

Reading

readInt Source #

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 Int
-> ReadS a

Reads an unsigned integral value in an arbitrary base.

readDec :: (Eq a, Num a) => ReadS a Source #

Read an unsigned number in decimal notation.

>>> readDec "0644"** **[(644,"")]

readHex :: (Eq a, Num a) => ReadS a Source #

Read an unsigned number in hexadecimal notation. Both upper or lower case letters are allowed.

>>> readHex "deadbeef"** **[(3735928559,"")]

readFloat :: RealFrac a => ReadS a Source #

Reads an unsigned [RealFrac](Prelude.html#t:RealFrac "Prelude") 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](GHC-Exts.html#t:Float "GHC.Exts")) are encouraged to instead use read, which does not suffer from this issue.

Miscellaneous

class Fractional a => Floating a where Source #

Trigonometric and hyperbolic functions and related functions.

The Haskell Report defines no laws for [Floating](Numeric.html#t:Floating "Numeric"). However, (`[+](Prelude.html#v:-43- "Prelude")`), (`[*](Prelude.html#v:-42- "Prelude")`) and [exp](Numeric.html#v:exp "Numeric") are customarily expected to define an exponential field and have the following properties:

Minimal complete definition

pi, exp, log, sin, cos, asin, acos, atan, sinh, cosh, asinh, acosh, atanh