Entry: JS_NewNumberValue (Function)
Summary: Internal use only. Summary fragment.
Syntax:
JSBool JS_NewNumberValue(JSContext *cx, jsdouble d,
jsval *rval);
Argument Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
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_NewNumberValue creates a jsval containing a numeric 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 numeric value to assign to the jsval, and rval is the jsval into which the new JS numeric value is stored. Space for the new value is allocated from the JS garbage collection heap.
JS_NewNumberValue attempts to creates a temporary copy of the double value. First it copies the value into an integer variable and compares the double and integer values. If they match, then JS_NewNumber converts the integer to a JS value. If they do not match, JS_NewNumber calls JS_NewDouble to create a JS value containing the value of the original double. If the creation of the JS value is successful, the function returns JS_TRUE. Otherwise it returns JS_FALSE.
See also:
|
|
|