new Number()
- Since:
-
- 1.0.0
Methods
-
<static> getNullSafe(num)
-
Returns a non-null number, even if the object being passed is a null number.
If the passed-in object is a non-null number, then it is returned as-is.
Example usage:
mindsmine.Number.getNullSafe(null) // -Infinity mindsmine.Number.getNullSafe(undefined) // -Infinity mindsmine.Number.getNullSafe(NaN) // -Infinity mindsmine.Number.getNullSafe(100) // 100 mindsmine.Number.getNullSafe("") // -Infinity mindsmine.Number.getNullSafe("hello") // -Infinity mindsmine.Number.getNullSafe(true) // -Infinity
Parameters:
Name Type Description num
Number The number to safeguard against
null
.- Since:
-
- 1.0.0
Returns:
If num is
null
then Number.NEGATIVE_INFINITY.- Type
- Number
-
<static> getNumOfDigits(num)
-
Returns the number of digits in the passed in number
Parameters:
Name Type Description num
Number for which to count the number of digits in
- Since:
-
- 2.1.0
Returns:
number of digits
- Type
- Number
-
<static> getUniqueRandomNumbers(lowerBound, upperBound, arraySize)
-
Returns an array of pseudorandom int values between the specified lower bound (inclusive) and the specified upper bound (exclusive).
Parameters:
Name Type Description lowerBound
Number the least value returned
upperBound
Number the upper bound (exclusive)
arraySize
Number the number of unique random numbers expected
- Since:
-
- 2.1.0
- See:
Throws:
-
-
if any of the arguments are not numbers
- Type
- TypeError
-
-
-
if any of the arguments are negative integers
- Type
- Error
-
-
-
if lower bound is greater than or equal to upper bound
- Type
- Error
-
Returns:
an array of pseudorandom integer values between the lower bound (inclusive) and the upper bound (exclusive).
- Type
- Array
-
<static> isNumber(obj)
-
Returns
true
if object is a NumberExample usage:
mindsmine.Number.isNumber(null) // false mindsmine.Number.isNumber(undefined) // false mindsmine.Number.isNumber(NaN) // false mindsmine.Number.isNumber(100) // true mindsmine.Number.isNumber("") // false mindsmine.Number.isNumber("hello") // false mindsmine.Number.isNumber(true) // false mindsmine.Number.isNumber(function() {}) // false mindsmine.Number.isNumber([]) // false mindsmine.Number.isNumber({}) // false
Parameters:
Name Type Description obj
Object The object to test
- Since:
-
- 2.1.0
Returns:
Whether or not the object is a Number
- Type
- Boolean
-
<static> isPerfectSquare(num)
-
Returns
true
if number is a Perfect SquareExample usage:
mindsmine.Number.isPerfectSquare(0) // true mindsmine.Number.isPerfectSquare(1) // true mindsmine.Number.isPerfectSquare(81) // true mindsmine.Number.isPerfectSquare(100) // true mindsmine.Number.isPerfectSquare(5) // false mindsmine.Number.isPerfectSquare(101) // false mindsmine.Number.isPerfectSquare(250) // false
Parameters:
Name Type Description num
Number The number to test
- Since:
-
- 3.1.0
- See:
Returns:
Whether or not the number is a Perfect Square
- Type
- Boolean