INT_FITS_IN_JSVAL

  • Revision slug: SpiderMonkey/JSAPI_Reference/INT_FITS_IN_JSVAL
  • Revision title: INT_FITS_IN_JSVAL
  • Revision id: 101815
  • Created:
  • Creator: MMondor
  • Is current revision? No
  • Comment

Revision Content

<title>INT_FITS_IN_JSVAL</title> {{template.Jsapiref()}}

Summary

Macro

Determines if a specified value is a valid JS integer.

Syntax

int INT_FITS_IN_JSVAL(int i);
Name Type Description
i int C integer value to evaluate.

Description

Determines if a specified C integer value, i, lies within the minimum and maximum ranges allowed for a jsval integer. If the value is within range, it can become a valid JS integer, and INT_FITS_IN_JSVAL is TRUE. Otherwise INT_FITS_IN_JSVAL is FALSE.

Example

The following code snippet illustrates how a JavaScript variable, item, is conditionally tested in an if statement to see if it is a legal integer value.

if (INT_FITS_IN_JSVAL(item)) {
    /* ... */
} else
    JS_ReportError(cx, "Integer out of range: %s", item);

See Also

Groups Macros
Documents {{template.LXRSearch("ident", "i", "INT_FITS_IN_JSVAL", "LXR ID Search")}}
Entries INT_TO_JSVAL, JSVAL_TO_INT

Revision Source

<p> &lt;title&gt;INT_FITS_IN_JSVAL&lt;/title&gt;
{{template.Jsapiref()}}
</p>
<h3 name="Summary"> Summary </h3>
<p><b>Macro</b>
</p><p>Determines if a specified value is a valid JS integer.
</p>
<h3 name="Syntax"> Syntax </h3>
<pre>int INT_FITS_IN_JSVAL(int i);
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>i</code></td>
<td><code>int</code></td>
<td>C integer value to evaluate.</td>
</tr>
</tbody></table>
<h3 name="Description"> Description </h3>
<p>Determines if a specified C integer value, <code>i</code>, lies within the minimum and maximum ranges allowed for a <code>jsval</code> integer. If the value is within range, it can become a valid JS integer, and <code>INT_FITS_IN_JSVAL</code> is <code>TRUE</code>. Otherwise <code>INT_FITS_IN_JSVAL</code> is <code>FALSE</code>.
</p>
<h3 name="Example"> Example </h3>
<p>The following code snippet illustrates how a JavaScript variable, <code>item</code>, is conditionally tested in an <code>if</code> statement to see if it is a legal integer value.
</p>
<pre>if (INT_FITS_IN_JSVAL(item)) {
    /* ... */
} else
    JS_ReportError(cx, "Integer out of range: %s", item);
</pre>
<h3 name="See_Also"> See Also </h3>
<table class="fullwidth-table">
<tbody><tr>
<td>Groups</td>
<td><a href="en/JSAPI_Reference#Macros">Macros</a></td>
</tr>
<tr>
<td>Documents</td>
<td>{{template.LXRSearch("ident", "i", "INT_FITS_IN_JSVAL", "LXR ID Search")}}</td>
</tr>
<tr>
<td>Entries</td>
<td><a href="en/JSAPI_Reference/INT_TO_JSVAL">INT_TO_JSVAL</a>, <a href="en/JSAPI_Reference/JSVAL_TO_INT">JSVAL_TO_INT</a></td>
</tr>
</tbody></table>
Revert to this revision