Number.MAX_VALUE

  • Revision slug: JavaScript/Reference/Global_Objects/Number/MAX_VALUE
  • Revision title: MAX VALUE
  • Revision id: 310983
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

Summary

The maximum numeric value representable in JavaScript.

Property of Number
Implemented in JavaScript 1.1
ECMAScript Edition ECMAScript 1st Edition

Description

The MAX_VALUE property has a value of approximately 1.79E+308. Values larger than MAX_VALUE are represented as "Infinity".

Because MAX_VALUE is a static property of Number, you always use it as Number.MAX_VALUE, rather than as a property of a Number object you created.

Examples

Example: Using MAX_VALUE

The following code multiplies two numeric values. If the result is less than or equal to MAX_VALUE, the func1 function is called; otherwise, the func2 function is called.

if (num1 * num2 <= Number.MAX_VALUE) {
   func1();
} else {
   func2();
}

See also

Revision Source

<h2 id="Summary" name="Summary">Summary</h2>
<p>The maximum numeric value representable in JavaScript.</p>
<table class="standard-table">
  <thead>
    <tr>
      <th class="header" colspan="2">Property of <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Number"><code>Number</code></a></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Implemented in</td>
      <td>JavaScript 1.1</td>
    </tr>
    <tr>
      <td>ECMAScript Edition</td>
      <td>ECMAScript 1st Edition</td>
    </tr>
  </tbody>
</table>


<h2 id="Description" name="Description">Description</h2>
<p>The <code>MAX_VALUE</code> property has a value of approximately 1.79E+308. Values larger than <code>MAX_VALUE</code> are represented as "<code>Infinity</code>".</p>
<p>Because <code>MAX_VALUE</code> is a static property of <code>Number</code>, you always use it as <code>Number.MAX_VALUE</code>, rather than as a property of a <code>Number</code> object you created.</p>


<h2 id="Examples" name="Examples">Examples</h2>


<h3 id="Example:_Using_MAX_VALUE" name="Example:_Using_MAX_VALUE">Example: Using <code>MAX_VALUE</code></h3>
<p>The following code multiplies two numeric values. If the result is less than or equal to <code>MAX_VALUE</code>, the <code>func1</code> function is called; otherwise, the <code>func2</code> function is called.</p>
<pre class="brush:js">
if (num1 * num2 &lt;= Number.MAX_VALUE) {
   func1();
} else {
   func2();
}</pre>


<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Number/MIN_VALUE" title="JavaScript/Reference/Global_Objects/Number/MIN_VALUE">MIN_VALUE</a></li>
</ul>
Revert to this revision