Module
Data.Number.Format
- Package
- purescript-numbers
- Repository
- purescript/purescript-numbers
A module for formatting numbers as strings.
Usage:
> let x = 1234.56789
> toStringWith (precision 6) x
"1234.57"
> toStringWith (fixed 3) x
"1234.568"
> toStringWith (exponential 2) x
"1.23e+3"
The main method of this module is the toStringWith
function that accepts
a Format
argument which can be constructed through one of the smart
constructors precision
, fixed
and exponential
. Internally, the
number will be formatted with JavaScripts toPrecision
, toFixed
or
toExponential
.
#exponential Source
exponential :: Int -> Format
Create a toExponential
-based format from an integer. Values smaller than
0
and larger than 20
will be clamped.