max integer value in JavaScript

前端 未结 3 1949
孤街浪徒
孤街浪徒 2020-12-05 19:43

I\'m reading the second chapter of the book Eloquent JavaScript. The author states that:

Any whole number less than 2^52 (which is more than 10^

3条回答
  •  隐瞒了意图╮
    2020-12-05 20:05

    This is not a strongly typed programming language. JS has an object Number. You can even get an infinite number: document.write(Math.exp(1000));.

    document.write(Number.MIN_VALUE + "
    "); document.write(Number.MAX_VALUE + "
    "); document.write(Number.POSITIVE_INFINITY + "
    "); document.write(Number.NEGATIVE_INFINITY + "
    "); alert([ Number.MAX_VALUE/(1e293), Number.MAX_VALUE/(1e292), Number.MAX_VALUE/(1e291), Number.MAX_VALUE/(1e290), ].join('\n'))

    Hope it's a useful answer. Thanks!

    UPDATE: max int is - +/- 9007199254740992

提交回复
热议问题