Package

numbers

Repository
purerl/purescript-numbers
Uploaded by
nwolverson

Latest release Build status Pursuit

Utility functions for working with PureScripts builtin Number type.

Installation

spago install numbers

Examples

Parsing:

> fromString "12.34"
(Just 12.34)

> fromString "1e-3"
(Just 0.001)

Formatting (Data.Number.Format):

> let x = 1234.56789

> toStringWith (precision 6) x
"1234.57"

> toStringWith (fixed 3) x
"1234.568"

> toStringWith (exponential 2) x
"1.23e+3"

Approximate comparisons (Data.Number.Approximate):

> 0.1 + 0.2 == 0.3
false

> 0.1 + 0.20.3
true

NaN and infinity:

> isNaN (Math.asin 2.0)
true

> isFinite (1.0 / 0.0)
false

Documentation

Module documentation is published on Pursuit.

Modules
Data.Number
Data.Number.Approximate
Data.Number.Format
Dependencies