You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
736 B

=proto
double duk_to_number(duk_context *ctx, int index);
=stack
[ ... val! ... ] -> [ ... ToNumber(val)! ... ]
=summary
<p>Replace the value at <tt>index</tt> with an Ecmascript
<a href="http://www.ecma-international.org/ecma-262/5.1/#sec-9.3">ToNumber()</a>
coerced value. Returns the coerced value. If <tt>index</tt> is invalid, throws
an error.</p>
<p>Custom type coercion:</p>
<ul>
<li>Buffer: <tt>0</tt> for zero-size buffer, <tt>1</tt> otherwise</li>
<li>Pointer: <tt>0</tt> for <tt>NULL</tt> pointer, <tt>1</tt> otherwise</li>
</ul>
=example
printf("coerced number: %lf\n", duk_to_number(ctx, -3));
=tags
stack
=fixme
Are the current custom coercions sensible? For instance, should pointer
coerce to its numeric value?