Try Install Learn Blog API Packages GitHub
Pages
core

Search
Entities

Number

Functions

format
(
number
:
Number
prefix
:
String
)
:
String

Formats the given number using the given 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 given number is even.

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

Returns true if given number is NaN.

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

Returns true if given number is odd.

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

Formats a number using fixed-point notation.

The first arguments specifies 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