2 ms·
Its one of the reasons. If you want more details you can check out this talk from Lua's main designer: video: https://www.youtube.com/watch?v=bjqNK1jA77M https
by ufo 12y ago
Its one of the reasons. If you want more details you can check out this talk from Lua's main designer:
video: https://www.youtube.com/watch?v=bjqNK1jA77M https://www.youtube.com/watch?v=bjqNK1jA77M
slides: http://www.inf.puc-rio.br/~roberto/talks/ws2014.pdf http://www.inf.puc-rio.br/~roberto/talks/ws2014.pdf
The main advantages of adding integers to Lua are:
* For some things you need 2^64 bits, not just 2^53 (file handles, crypto algorithms with bitwise operations, etc)
* Some embedded systems don't have hardware support for floating point (you could compile Lua with integers instead of double but it was very hacky)
* It simplifies the C API. There are some things in the API and various internals in the implementation that benefit from separating integers and floating point numbers.
- benhoyt 12y agoThanks for the links -- slides were very helpful. This makes sense.
- speeder 12y agoAnother information from someone using Lua for years: Sometimes the hardware/OS/drivers/something else is buggy with floats... I once designed a game that needed integers for some things, and implemented it with Lua, on Windows machines it started to sometimes give VERY WRONG results (even in very short operations, like reporting that 5+5 == 11 or that 8+2 == 9, those are actual errors, not just short numbers to make typing easier). Later I found out it had to do with a infamous directX bug, where it changed the settings of the floating point units without permission, and sometimes this resulted into really, really, really funky floating point math, meaning that all math made with Lua in those cases maybe could be completely wrong. Back then when I found this (The issue, not the reason for it), many Lua devs kept telling me I as crazy or a troll, thankfully one guy in freenode.net #lua had the brilliance to tell me to check if it was the DX issue (and it was... the issue don't happened on Linux or OSX)