@reyalp
One after thought is related to the current integer math limitation of multiplying two numbers, ie not using the imath library, and ensuring these are less than , assuming I’ve got that right.
Could there be any value in an integer Lua version able to use larger numbers? That is greater than 32bits.
Lua in CHDK is currently configured to use 32 bit (signed) integers for the "number" type. This is what the processor does natively, and Lua as a language does not have a concept of unsigned numbers.
Lua could configured to use 64 bit numbers, but this would have similar performance and memory impacts to using floating point, and would likely have some compatibility issues with the existing CHDK interface. If someone were going to invest time in this, I'd think the floating point option would be a better choice.
There is another option: You could use
metamethods to implement a new datatype that supports the usual mathematical operations for float, 64 bit ints, or even arbitrary precision. While you could theoretically do this in pure Lua, it would be better done with
userdata and with C code to implement the underlying operations. This would have the minimum impact on existing code, at the expense of being somewhat less convenient to work with.
A C implementation would still bloat the Lua module, until we add the capability to load C modules in Lua. This is something I want to add, probably higher on my priority list than supporting alternative number types.