JavaScript(JS) number method - negative_infinity
The Number.NEGATIVE_INFINITY
property in JavaScript represents the negative infinity value, which is a special value that represents a number that is lower than any other number. It is a property of the global Number
object.
Here's an example usage:
console.log(Number.NEGATIVE_INFINITY); // -Infinity console.log(1 / Number.NEGATIVE_INFINITY); // -0 console.log(-1 / Number.NEGATIVE_INFINITY); // 0
In the above example, Number.NEGATIVE_INFINITY
is used to represent the negative infinity value. The second call evaluates to negative zero (-0
) because dividing a positive number by negative infinity results in a negative number that is too small to be represented by the double-precision floating-point format, so it evaluates to negative zero. The third call evaluates to positive zero (0
) because dividing a negative number by negative infinity results in a positive number that is too small to be represented by the double-precision floating-point format, so it evaluates to positive zero.