Module

Data.Decimal

Package
purescript-decimals
Repository
sharkdp/purescript-decimals

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

#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"

#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.

#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.

#acot Source

acot :: Decimal -> Decimal

Inverse cotangent.

Note that this is a multivalued function. The definition here refers to the principal value of 'acot' without a discontinuity at x=0, and a domain of (0, π). See https://mathworld.wolfram.com/InverseCotangent.html for more information.

#acoth Source

acoth :: Decimal -> Decimal

Inverse hyperbolic cotangent.

#acsc Source

acsc :: Decimal -> Decimal

Inverse cosecant.

#acsch Source

acsch :: Decimal -> Decimal

Inverse hyperbolic cosecant.

#asec Source

asec :: Decimal -> Decimal

Inverse secant.

#asech Source

asech :: Decimal -> Decimal

Inverse hyperbolic secant.

#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.

#clamp Source

clamp :: Decimal -> Decimal -> Decimal -> Decimal

Clamp a number to the range delineated by the first two parameters.

#cos Source

cos :: Decimal -> Decimal

Cosine.

#cosh Source

cosh :: Decimal -> Decimal

Hyperbolic cosine.

#cot Source

cot :: Decimal -> Decimal

Cotangent.

#coth Source

coth :: Decimal -> Decimal

Hyperbolic cotangent.

#csc Source

csc :: Decimal -> Decimal

Cosecant.

#csch Source

csch :: Decimal -> Decimal

Hyperbolic cosecant.

#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.

#sec Source

sec :: Decimal -> Decimal

Secant.

#sech Source

sech :: Decimal -> Decimal

Hyperbolic secant.

#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