How do I check if a number evaluates to infinity?

前端 未结 7 819
孤城傲影
孤城傲影 2020-12-07 19:24

I have a series of Javascript calculations that (only under IE) show Infinity depending on user choices.

How does one stop the word Infinity appearing a

7条回答
  •  渐次进展
    2020-12-07 20:06

    Actually n === n + 1 will work for numbers bigger than 51 bit, e.g.

    1e16 + 1 === 1e16; // true
    1e16 === Infinity; // false
    

提交回复
热议问题