Int Extensions

Omar Albeik edited this page Dec 12, 2016 · 4 revisions

Int extensions

Properties:

Name Description
abs Absolute value of integer.
asLocaleCurrency String with number and current locale currency.
degreesToRadians Radian value of degree input.
digits Array of digits of integer value.
digitsCount Number of digits of integer value.
isEven Check if integer is even.
isOdd Check if integer is odd.
radiansToDegrees Degree value of radian input
romanNumeral Roman numeral string from integer (if applicable).
timeString String of format (XXh XXm) from seconds Int
kFormatted String formatted for values over ±1000 (example: 1k, -2k, 100k, 1kk, -5kk..)

Methods:

Name Return Description
gcd(of n: Int) Int Greatest common divisor of integer value and n.
lcm(of n: Int) Int Least common multiple of integer and n.
randomBetween(min: Int, max: Int) Int Random integer between two integer values.

Operators:

Name Return Description
** Int Value of exponentiation (example: 2 ** 3 = 8).
Double Square root of float.
± (infix) (Int, Int) Tuple of plus-minus operation (example: 2 ± 3 -> (5, -1)).
± (prefix) (Int, Int) Tuple of plus-minus operation (example: ± 2 -> (2, -2)).