I need to work with really big numbers that go way beyond Lua limits. I liked this library, but it needs Lua 5.3…
There is also this BigNum library, but the rational version don’t seems quite what I want (It works with “x / y” format, I want the whole value directly). And I’m not capable of creating such library myself, it is way out of my league.
So, would anyone know a possible solution? Is there any big number libraries I could use with Lua 5.1?
Hi @rafael-lua!
Although I don’t know about any “big num” libraries, I’m curious about your use case? Perhaps you can tell us a bit more about what you want to do, and maybe we can help?
Sure thing. I work with incremental games. Numbers go up non stop, very often exponentially. Lua precision for integers goes only to 2^52. I imagine that floats are even smaller for precision. BigNum libraries (like this in js) would allow me work with obscene numbers without losing much precision and without limit.
Without such library, I have a very limited value to work with (For this genre of game), up to quadrillions more or less.
In case it’s not possible, it looks like this workaround can be useful even though it’s not 100% accurate.
=> I’m supposed to have a 100% round integer but the accuracy level seems to be good enough for my needs. So I can probably do something with that (same for anyone wanting to create an idle game with big numbers).
Note: would be nice to have a Defold extension to deal with big numbers (anyone developing an idle/big number-based game would use it), unfortunately as you can see I’m far from being able to develop it myself…