Possible typo with define tonumberns?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Possible typo with define tonumberns?

Ranier Vilela-2
Possible typo with define tonumberns?

Should it be?

#define tonumberns(o,n) \
(ttisfloat(o) ? (*(n) = fltvalue(o), 1) : \
(ttisinteger(o) ? (*(n) = cast_num(ivalue(o)), 1) : 0))

regards,

Ranier Vilela

fix_typo_tonumberns.patch (664 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Possible typo with define tonumberns?

Ahmed Charles-2
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Monday, October 26, 2020 4:04 PM, Ranier Vilela <[hidden email]> wrote:

> Possible typo with define tonumberns?
>
> Should it be?
>
> #define tonumberns(o,n) \
> (ttisfloat(o) ? (*(n) = fltvalue(o), 1) : \
> (ttisinteger(o) ? (*(n) = cast_num(ivalue(o)), 1) : 0))

Note: the macro is used (consistently) as `tonumberns(p1, n1)`, where n1 is `lua_Number n1;`. n isn't a pointer, it's a number. Every binary operation between two lua_Number's goes through this macro, so it definitely works as is, or at least, it doesn't have a typo which is this trivial.