A safe integer is an integer that can be exactly represented as an IEEE-754 double precision number [ all integers from (253 - 1) to -(253 - 1) ].
The syntax of the isSafeInteger() method is:
Number.isSafeInteger(testValue)
The isSafeInteger() method is called using the Number class name.
Number isSafeInteger() Parameters
The isSafeInteger() method takes in:
- testValue - The value to be tested for being a safe integer.
Return value from Number isSafeInteger()
- Returns a
Booleanindicating whether or not the given value is a number that is a safe integer (trueif safe integer elsefalse).
Example: Using Number.isSafeInteger()
Output
true false false false true false true
Recommended Readings: