Module

Data.Decimal

Package
purescript-decimals
Repository
sharkdp/purescript-decimals

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

#fromInt Source

fromInt :: Int -> Decimal

Convert an integer to a Decimal.

#fromNumber Source

fromNumber :: Number -> Decimal

Convert a number to a Decimal.

#toNumber Source

toNumber :: Decimal -> Number

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

#fromString Source

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"

#toString Source

toString :: Decimal -> String

A representation of the Decimal as a String.

#toPrecision Source

toPrecision :: Int -> Decimal -> String

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

#toFixed Source

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 Source

isFinite :: Decimal -> Boolean

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

#isInteger Source

isInteger :: Decimal -> Boolean

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

#toSignificantDigits Source

toSignificantDigits :: Int -> Decimal -> Decimal

Round to the given number of significant digits.

#abs Source

abs :: Decimal -> Decimal

The absolute value.

#acos Source

acos :: Decimal -> Decimal

Inverse cosine.

#acosh Source

acosh :: Decimal -> Decimal

Inverse hyperbolic cosine.

#asin Source

asin :: Decimal -> Decimal

Hyperbolic sine.

#asinh Source

asinh :: Decimal -> Decimal

Inverse hyperbolic sine.

#atan Source

atan :: Decimal -> Decimal

Inverse tangent.

#atan2 Source

atan2 :: Decimal -> Decimal -> Decimal

Inverse hyperbolic tangent.

#atanh Source

atanh :: Decimal -> Decimal

Inverse hyperbolic tangent.

#ceil Source

ceil :: Decimal -> Decimal

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

#cos Source

cos :: Decimal -> Decimal

Cosine.

#cosh Source

cosh :: Decimal -> Decimal

Hyperbolic cosine.

#exp Source

exp :: Decimal -> Decimal

Exponential function.

#floor Source

floor :: Decimal -> Decimal

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

#ln Source

ln :: Decimal -> Decimal

Natural logarithm.

#log2 Source

log2 :: Decimal -> Decimal

Logarithm with base 2.

#log10 Source

log10 :: Decimal -> Decimal

Logarithm with base 10.

#max Source

max :: Decimal -> Decimal -> Decimal

The larger of two numbers.

#min Source

min :: Decimal -> Decimal -> Decimal

The smaller of two numbers.

#modulo Source

modulo :: Decimal -> Decimal -> Decimal

Modulo operation.

#pow Source

pow :: Decimal -> Decimal -> Decimal

Exponentiation for Decimal.

#round Source

round :: Decimal -> Decimal

Round to the nearest whole number.

#sin Source

sin :: Decimal -> Decimal

Sine.

#sinh Source

sinh :: Decimal -> Decimal

Hyperbolic sine.

#sqrt Source

sqrt :: Decimal -> Decimal

Square root.

#tan Source

tan :: Decimal -> Decimal

Tangent.

#tanh Source

tanh :: Decimal -> Decimal

Hyperbolic tangent.

#truncated Source

truncated :: Decimal -> Decimal

Truncate to an integer by removing the mantissa.

#e Source

e :: Decimal

Euler's number.

#pi Source

pi :: Decimal

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

#gamma Source

gamma :: Decimal -> Decimal

The gamma function.

#factorial Source

factorial :: Decimal -> Decimal

The factorial function.

Modules
Data.Decimal