Giter Site home page Giter Site logo

int64 result is error about luajit2 HOT 8 OPEN

openresty avatar openresty commented on July 23, 2024
int64 result is error

from luajit2.

Comments (8)

vanc avatar vanc commented on July 23, 2024 3

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

from luajit2.

nt47 avatar nt47 commented on July 23, 2024

how to increase size to 32 simbols?

from luajit2.

nt47 avatar nt47 commented on July 23, 2024

hello? creators ? little bird needs you

from luajit2.

AlexKordic avatar AlexKordic commented on July 23, 2024

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

Really strange to post textual question using image. Distasteful.

from luajit2.

vanc avatar vanc commented on July 23, 2024

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

from luajit2.

nt47 avatar nt47 commented on July 23, 2024

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 ?

from luajit2.

vanc avatar vanc commented on July 23, 2024

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.

from luajit2.

nt47 avatar nt47 commented on July 23, 2024

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 ?

from luajit2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.