Try Install Learn Blog API Packages GitHub
Pages

Number

Functions

format
(
prefix
:
String
number
:
Number
)
:
String

Formats the given number using the griven prefix and separating the digits by 3 with a comma.

Number.format("$ ", 1034150) == "$ 1,034,150"
fromString
(
input
:
String
)
:
Maybe(Number)

Tries to parse the given string into a number.

Number.fromString("asd") == Maybe.nothing()
Number.fromString("012") == Maybe.just(12)
isEven
(
input
:
Number
)
:
Bool

Returns true if number is even.

Number.isEven(1) == true
Number.isEven(2) == false
isNaN
(
input
:
Number
)
:
Bool

Returns true if a number is a NaN.

Number.isNaN(`NaN`) == true
Number.isNaN(0) == false
isOdd
(
input
:
Number
)
:
Bool

Returns true if number is odd.

Number.isOdd(1) == false
Number.isOdd(2) == true
toFixed
(
decimalPlaces
:
Number
input
:
Number
)
:
String

Formats a number using fixed-point notation.

The first arguments speficies the number of digits to appear after the decimal point, it can be between 0 and 20.

Number.toFixed(2, 0.1234567) == "0.12"
toString
(
input
:
Number
)
:
String

Returns the string representation of the given number.

Number.toString(123) == 123