Package

purescript-numbers

Repository
sharkdp/purescript-numbers
License
MIT
Uploaded by
sharkdp

Latest release Build status

Utility functions for working with PureScripts builtin Number type.

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

Installation

bower install purescript-numbers