JavaScript(JS) number method - positive_infinity
The Number.POSITIVE_INFINITY
property in JavaScript represents the positive infinity value, which is a special value that represents a number that is greater than any other number. It is a property of the global Number
object.
Here's an example usage:
refer to:igiftidea.comconsole.log(Number.POSITIVE_INFINITY); // Infinity console.log(1 / Number.POSITIVE_INFINITY); // 0 console.log(-1 / Number.POSITIVE_INFINITY); // -0
In the above example, Number.POSITIVE_INFINITY
is used to represent the positive infinity value. The second call evaluates to positive zero (0
) because dividing a positive number by positive 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. The third call evaluates to negative zero (-0
) because dividing a negative number by positive 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.