JavaScript Reference ยท Number and BigInt
Number.MAX_VALUE and Number.MIN_VALUE
Reference for Number.MAX_VALUE and Number.MIN_VALUE: the largest finite and smallest positive doubles, overflow to Infinity, underflow to 0 and common mistakes.
Number.MAX_VALUE is the largest finite number JavaScript can represent, about 1.7976931348623157e+308. Number.MIN_VALUE is the smallest positive number greater than zero, 5e-324.
A calculation that grows past MAX_VALUE becomes Infinity; one that shrinks below MIN_VALUE becomes 0. Neither constant is about integers: for exact whole numbers see Number.MAX_SAFE_INTEGER.
Number.MAX_VALUE Number.MIN_VALUE
Try it
Press Run (or Ctrl + Enter) to see the console output here.
No output.
Press Run (or Ctrl + Enter) to see the console output here.
No output.
Syntax
Number.MAX_VALUE // 1.7976931348623157e+308 Number.MIN_VALUE // 5e-324
| Part | Description |
|---|---|
MAX_VALUE |
The largest positive finite double, (2 - 2 ** -52) * 2 ** 1023. |
MIN_VALUE |
The smallest positive double (a subnormal), 2 ** -1074. |
| Attributes | Not writable, not enumerable, not configurable. |
Usage notes
MIN_VALUEis positive. It is the closest positive number to zero, not the most negative number. The most negative finite value is-Number.MAX_VALUE.- Initial values for searches: use
Infinityand-Infinity(or the first element) rather thanMAX_VALUE/MIN_VALUEwhen looking for a minimum or maximum. - Overflow gives
Infinity, not an error. Test results withNumber.isFinite(). - Underflow gives
0, possibly-0. The sign is kept:-Number.MIN_VALUE / 2is-0. - Precision shrinks with size. Near
MAX_VALUEneighbouring doubles are about2e292apart, so adding small numbers changes nothing. - Integers beyond
MAX_SAFE_INTEGERare inexact long beforeMAX_VALUE. UseBigIntfor huge exact integers. - Parsing:
Number("1e309")isInfinity, andNumber("1e-400")is0.
Browser support
Supported in every browser and JavaScript engine.