JS_NewDoubleValue

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_NewDoubleValue
  • Revision title: JS_NewDoubleValue
  • Revision id: 69183
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment /* Syntax */ Requires request.

Revision Content

{{template.Jsapiref()}}

Summary

Creates a JS value based on a JS double.

Syntax

JSBool JS_NewDoubleValue(JSContext *cx, jsdouble d, jsval *rval);
Name Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information. {{wiki.template('Jsapi-requires-request')}}
d jsdouble An existing double to assign as a value to the jsval.
rval jsval * Pointer to a previously declared jsval into which to store the double value.

Description

JS_NewDoubleValue creates a jsval containing a double value that corresponds to the double passed in as an argument. cx is the executable script context in which this call is made. d is the double value to assign to the jsval, and rval is the jsval into which the new JS double value is stored. Space for the new value is allocated from the JS garbage collection heap.

JS_NewDoubleValue attempts to creates a temporary copy of the double value. If the copy is successful, then the jsval is created, and the function returns JS_TRUE. Otherwise it returns JS_FALSE.

Notes

After you create it, a JS double is subject to garbage collection until you protect against it using a local root, an object property, or the JS_AddRoot function.

See Also

Groups Functions
Documents {{template.LXRSearch("ident", "i", "JS_NewDoubleValue", "LXR ID Search")}}
Entries

JS_AddRoot, JS_NewNumberValue

Revision Source

<p> 
{{template.Jsapiref()}}
</p>
<h2 name="Summary"> Summary </h2>
<p>Creates a JS value based on a JS double.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre>JSBool JS_NewDoubleValue(JSContext *cx, jsdouble d, jsval *rval);
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>cx</code></td>
<td><code>JSContext *</code></td>
<td>Pointer to a JS context from which to derive runtime information.
{{wiki.template('Jsapi-requires-request')}}</td>
</tr>
<tr>
<td><code>d</code></td>
<td><code>jsdouble</code></td>
<td>An existing <code>double</code> to assign as a value to the <code>jsval</code>.</td>
</tr>
<tr>
<td><code>rval</code></td>
<td><code>jsval *</code></td>
<td>Pointer to a previously declared <code>jsval</code> into which to store the <code>double</code> value.</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<p><code>JS_NewDoubleValue</code> creates a <code>jsval</code> containing a <code>double</code> value that corresponds to the <code>double</code> passed in as an argument. <code>cx</code> is the executable script context in which this call is made. <code>d</code> is the <code>double</code> value to assign to the <code>jsval</code>, and <code>rval</code> is the <code>jsval</code> into which the new JS <code>double</code> value is stored. Space for the new value is allocated from the JS garbage collection heap.
</p><p><code>JS_NewDoubleValue</code> attempts to creates a temporary copy of the <code>double</code> value. If the copy is successful, then the <code>jsval</code> is created, and the function returns <code>JS_TRUE</code>. Otherwise it returns <code>JS_FALSE</code>.
</p>
<h3 name="Notes"> Notes </h3>
<p>After you create it, a JS double is subject to garbage collection until you protect against it using a local root, an object property, or the <code><a href="en/JS_AddRoot">JS_AddRoot</a></code> function.
</p>
<h2 name="See_Also"> See Also </h2>
<table class="fullwidth-table">
<tbody><tr>
<td>Groups</td>
<td><a href="en/JSAPI_Reference#Functions">Functions</a></td>
</tr>
<tr>
<td>Documents</td>
<td>{{template.LXRSearch("ident", "i", "JS_NewDoubleValue", "LXR ID Search")}}</td>
</tr>
<tr>
<td>Entries</td>
<td>
<p><a href="en/JS_AddRoot">JS_AddRoot</a>,
<a href="en/JS_NewNumberValue">JS_NewNumberValue</a>
</p>
</td>
</tr>
</tbody></table>
Revert to this revision