new NumUtils()
Util methods about number.
- Source:
Methods
-
(static) getPrimes(max) → {Array}
-
Returns a primes array from 2 to max number.
Parameters:
Name Type Description maxInt - Source:
Returns:
- Type
- Array
-
(static) isFloatEqual(f1, f2, threshold) → {Bool}
-
Check if f1 and f2 are equal. Since float can not be stored exactly in computer, when abs(f1-f2) <= threshold, this function will returns true.
Parameters:
Name Type Description f1Float f2Float thresholdFloat If not set, a default value will be used. - Source:
Returns:
- Type
- Bool
-
(static) isInteger(num) → {Bool}
-
Check if a number is integer.
Parameters:
Name Type Description numNumber - Source:
Returns:
- Type
- Bool
-
(static) toDecimals(num, decimalsLength) → {String}
-
Output a string with decimalsLength. Not the same to Number.toFixed, this method will not pad with zero. For example, call toDecimals(5.3456, 2) will return '5.35', but call toDecimals(5.1, 2) will simply return '5.1',
Parameters:
Name Type Description numNumber decimalsLengthInt - Source:
Returns:
- Type
- String