Numeric functions
decimal()
β
Round the given number at the given scale using the given rounding mode. If no rounding mode is passed in then it uses HALF_EVEN
as default.
- parameters:
n
: numberscale
: number- (optional)
mode
: string - one ofUP, DOWN, CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_EVEN, UNNECESSARY
(default:HALF_EVEN
)
- result: number
decimal(1/3, 2)
// .33
decimal(1.5, 0)
// 2
decimal(2.5, 0, "half_up")
// 3
floor()
β
- parameters:
n
: number
- result: number
floor(1.5)
// 1
floor(-1.5)
// -2
ceiling()
β
- parameters:
n
: number
- result: number
ceiling(1.5)
// 2
floor(-1.5)
// -1
abs()
β
- parameters:
number
: number
- result: number
abs(10)
// 10
abs(-10)
// 10
modulo()
β
Returns the remainder of the division of dividend by divisor.
- parameters:
dividend
: numberdivisor
: number
- result: number
modulo(12, 5)
// 2
sqrt()
β
Returns the square root.
- parameters:
number
: number
- result: number
sqrt(16)
// 4
log()
β
Returns the natural logarithm (base e) of the number.
- parameters:
number
: number
- result: number
log(10)
// 2.302585092994046
exp()
β
Returns the Eulerβs number e raised to the power of number .
- parameters:
number
: number
- result: number
exp(5)
// 148.4131591025766
odd()
β
- parameters:
number
: number
- result: boolean
odd(5)
// true
even()
β
- parameters:
number
: number
- result: boolean
odd(5)
// false