Subj : spidermonkey docu To : netscape.public.mozilla.jseng From : Jens Thiele Date : Wed Apr 07 2004 08:09 am the JS_ValueToInt32 docu is wrong: http://mozilla.org/js/spidermonkey/apidoc/gen/complete.html#JS_ValueToInt32 Description JS_ValueToInt32 converts a specified JS value, v, to a JS double, and then to a 32-bit integer, if it fits. If the double is out of range, JS_ValueToInt32 reports an error and conversion fails. The double rounded to the nearest integer value. the corresponding source: js_ValueToInt32(JSContext *cx, jsval v, int32 *ip) { jsdouble d; JSString *str; if (JSVAL_IS_INT(v)) { *ip = JSVAL_TO_INT(v); return JS_TRUE; } [...] => js_ValueToInt32 does IMHO the right thing ;-) if it is a JS int value convert to C int32 if not try to convert it to an C int32 .