Skip to content

purescm/purescript-numbers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

purescript-numbers

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.

About

Functions for working with PureScripts 'Number' type

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PureScript 95.2%
  • JavaScript 4.8%