lua-users home
lua-l archive

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


2012/5/21 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>> I just have a idea that replace lua_Number as a GMP number or MAPM
>> number, is that possible? I mean, A lua with native big number
>> support?
>
> I think Gavin Wraith once used MAPM in RiscLua:
>        http://lua-users.org/lists/lua-l/2006-04/msg00168.html
>
> I haven't tried this yet but it shoud be reasonably simple due to the
> existence of the luai_num* macros in luaconf.h. However, I expect that
> there will be some issues with memory management because Lua does not
> garbage collect numbers and so you cannot tell the underlying library
> to free big numbers.
>
> Anyway, I'd like to hear about your efforts.
>

Thank you for information.

it seems that he use integer as lua number, for avoid performance
issues. but I just curious about using a big number as Lua's number.
e.g. I can do this:
> print(2^100)
1267650600200000000000000000000

the issue is not at memory garbage: using C++ class means you can
using C++ operations, such as operator= or copy constructor. the issue
is this class is in a union: that means C++ don't know call which copy
constructor if you call setobj :-(

so maybe I need make a function version of setobj and something others.

regards,
Xavier Wang.