lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 26.06.2016 um 13:12 schröbte Mooffie:
On 6/26/16, Sean Conner <sean@conman.org> wrote:
The safest course is to check that the result (as a double) fits in the
"safe" range and if not,
While this was not at all my original concern, you helped me to decide
that I should have a function dedicated to getting huge integers from
the Lua stack. BTW, do you know of a simple way of checking that a
floating number is in the safe integer range?
The constants `FLT_RADIX` (usually 2) and `DBL_MANT_DIG` (probably 53 in 
your case) can be found in the ISO C header `float.h`. There's also 
`FLT_MANT_DIG` (for float) and `LDBL_MANT_DIG` (for long double) in case 
you want to handle non-standard `lua_Number` types.
Philipp