luajit2 icon indicating copy to clipboard operation
luajit2 copied to clipboard

int64 result is error

Open nt47 opened this issue 6 years ago • 8 comments

a-b=0??? QQ图片20190809202854

nt47 avatar Aug 09 '19 12:08 nt47

how to increase size to 32 simbols?

nt47 avatar Aug 09 '19 12:08 nt47

hello? creators ? little bird needs you

nt47 avatar Aug 09 '19 12:08 nt47

Maybe use BigNum library? Like this one https://github.com/user-none/lua-nums ?

Really strange to post textual question using image. Distasteful.

AlexKordic avatar Aug 09 '19 17:08 AlexKordic

You can use ffi to workaround big integer issue. It should be easier than using a big number library.

ffi=require'ffi' a=ffi.new('uint64_t', 9223372036854775807ull) =a 9223372036854775807ULL b=ffi.new('uint64_t', 9223372036854775806ull) =b 9223372036854775806ULL c=a-b =c 1ULL d=c =d 1ULL =tonumber(d) 1

vanc avatar Aug 12 '19 19:08 vanc

Actually, you don't need to use the ffi function directly. LuaJIT does the boxing/unboxing automatically. Just need to tell it's a long number by appending the "ll" modifer.

a=9223372036854775807ll b=9223372036854775806ll =a-b 1LL

vanc avatar Aug 12 '19 20:08 vanc

Actually, you don't need to use the ffi function directly. LuaJIT does the boxing/unboxing automatically. Just need to tell it's a long number by appending the "ll" modifer.

a=9223372036854775807ll b=9223372036854775806ll =a-b 1LL

no, this way is not good,i just want to use int64 without ll, and can use tostring,can u tell me how to compile luajit for int64 ?

nt47 avatar Aug 13 '19 01:08 nt47

i just want to use int64 without ll

Unfortunately, you cannot do that. Lua can only store 64-bit integers up to 2^53. With LuaJIT, it automatically boxes 64-bit values in CDATA object when it detects the "ll" or "ull" modifiers.

can u tell me how to compile luajit for int64 ?

Don't understand your question. There is no special compile options for int64. Just use the standard source code and compile for your platform.

vanc avatar Aug 13 '19 01:08 vanc

i just want to use int64 without ll

Unfortunately, you cannot do that. Lua can only store 64-bit integers up to 2^53. With LuaJIT, it automatically boxes 64-bit values in CDATA object when it detects the "ll" or "ull" modifiers.

can u tell me how to compile luajit for int64 ?

Don't understand your question. There is no special compile options for int64. Just use the standard source code and compile for your platform.

omg,i don't want to use C# to wrapper my API...

can luajit2's developer can do it ?

nt47 avatar Aug 13 '19 01:08 nt47