NEGATIVE_INFINITY (JavaScript)
Negative infinity.
Defined in
Number (Standard - JavaScript)Syntax
Number.NEGATIVE_INFINITY
Usage
NEGATIVE_INFINITY is a constant and has the same value whether called statically as shown in the syntax or from an object.A negative number greater than MAX_VALUE has the value NEGATIVE_INFINITY.
NEGATIVE_INFINITY has the string representation -?
(minus
sign, question mark).
Division by zero results in infinity.
Examples
The following example prints negative infinity then shows that negative infinity is the result of a very large number or division by zero.function p(stuff) {
print("<<<" + stuff + ">>>");
}
try {
p(Number.NEGATIVE_INFINITY.toString()); // prints <<<-?>>>
p(Number.NEGATIVE_INFINITY.valueOf()); // prints <<<-Infinity>>>
var n = new Number(-1.7976931348623157E309);
if (n == Number.NEGATIVE_INFINITY) {
p(n + " = Number.NEGATIVE_INFINITY");
// prints <<<-Infinity = Number.NEGATIVE_INFINITY>>>
}
if ((-5/0) == Number.NEGATIVE_INFINITY) {
p("division by 0 = Number.NEGATIVE_INFINITY");
//prints <<<division by 0 = Number.NEGATIVE_INFINITY>>>
}
} catch(e) {
p("Error = " + e);
}