Module

Data.Decimal

This module defines a Decimal data type for arbitrary precision numbers.

#fromString

fromString :: String -> Maybe Decimal

Parse a string into a Decimal, assuming a decimal representation. Returns Nothing if the parse fails.

Examples:

fromString "42.001"
fromString "857981209301293808359384092830482"
fromString "1e100"
fromString "0.12301928309128183579487598149533"

#fromInt

fromInt :: Int -> Decimal

Convert an integer to a Decimal.

#fromNumber

fromNumber :: Number -> Decimal

Convert a number to a Decimal.

#toNumber

toNumber :: Decimal -> Number

Converts a Decimal to a Number, possibly resulting in loss of precision.

#toString

toString :: Decimal -> String

A representation of the Decimal as a String.

#toPrecision

toPrecision :: Int -> Decimal -> String

A representation of the Decimal as a String, rounded to the given number of significant digits

#toFixed

toFixed :: Int -> Decimal -> String

A representation of the Decimal as a String in fixed-point notation rounded to the given number of decimal places. Never returns exponential notation. Uses the default rounding mode.

#isFinite

isFinite :: Decimal -> Boolean

Returns true if the value of this Decimal is a finite number (not infinite, not NaN).

#isInteger

isInteger :: Decimal -> Boolean

Returns true if the value of this Decimal is a whole number.

#toSignificantDigits

toSignificantDigits :: Int -> Decimal -> Decimal

Round to the given number of significant digits.

#abs

abs :: Decimal -> Decimal

The absolute value.

#acos

acos :: Decimal -> Decimal

Inverse cosine.

#acosh

acosh :: Decimal -> Decimal

Inverse hyperbolic cosine.

#asin

asin :: Decimal -> Decimal

Hyperbolic sine.

#asinh

asinh :: Decimal -> Decimal

Inverse hyperbolic sine.

#atan

atan :: Decimal -> Decimal

Inverse tangent.

#atan2

atan2 :: Decimal -> Decimal -> Decimal

Inverse hyperbolic tangent.

#atanh

atanh :: Decimal -> Decimal

Inverse hyperbolic tangent.

#ceil

ceil :: Decimal -> Decimal

Rounded to next whole number in the direction of +inf.

#cos

cos :: Decimal -> Decimal

Cosine.

#cosh

cosh :: Decimal -> Decimal

Hyperbolic cosine.

#exp

exp :: Decimal -> Decimal

Exponential function.

#floor

floor :: Decimal -> Decimal

Rounded to next whole number in the direction of -inf.

#ln

ln :: Decimal -> Decimal

Natural logarithm.

#log2

log2 :: Decimal -> Decimal

Logarithm with base 2.

#log10

log10 :: Decimal -> Decimal

Logarithm with base 10.

#max

max :: Decimal -> Decimal -> Decimal

The larger of two numbers.

#min

min :: Decimal -> Decimal -> Decimal

The smaller of two numbers.

#modulo

modulo :: Decimal -> Decimal -> Decimal

Modulo operation.

#pow

pow :: Decimal -> Decimal -> Decimal

Exponentiation for Decimal.

#round

round :: Decimal -> Decimal

Round to the nearest whole number.

#sin

sin :: Decimal -> Decimal

Sine.

#sinh

sinh :: Decimal -> Decimal

Hyperbolic sine.

#sqrt

sqrt :: Decimal -> Decimal

Square root.

#tan

tan :: Decimal -> Decimal

Tangent.

#tanh

tanh :: Decimal -> Decimal

Hyperbolic tangent.

#truncated

truncated :: Decimal -> Decimal

Truncate to an integer by removing the mantissa.

#e

e :: Decimal

Euler's number.

#pi

pi :: Decimal

Pi, the ratio of a circle's circumference to its diameter.

#gamma

gamma :: Decimal -> Decimal

The gamma function.

#factorial

factorial :: Decimal -> Decimal

The factorial function.

Modules