lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


The way I personnaly see the possible solutions, taking into accound the detailed answers to the thread (thank you to all contributors), would be to integrate the ldecnumber module with the LNUM patch.
 
This way, we could define the "context" (precision, etc., see the ldecnumber documentation) at run-time, and maybe even switch ldecnumber off to fallback on the normal Lua behaviour with doubles.
 
To me, that would also have the great advantage to fix the problem raised by Dirk Feytons ("relational operators are only possible on operands of the same type. In other words, you can't compare such a userdata object with a regular number since it is by definition false.") and which is kind of a show stopper for me.
 
Indeed, the calculations (Lua scripts) are provided by the users of my application, and I don't feel like explaining in the documentation that it is forbidden to test whether 1 < decNumber.tonumber("1.5") and that what they should write instead is: decNumber.tonumber("1") < decNumber.tonumber("1.5")...
 
That's why I'm thinking of integrating the ldecnumber module into the LNUM patch. What do you guys think about that?
I think that this would be a really great addition to the Lua language, offering to Lua all the power of arbitrary precision maths, without the previous side effects and without the added comlexity each time tou deal with numbers (decNumber.tonumber stuff, etc.)
 
Thank you for your insights.
Aladdin
 


Centralisez tous vos comptes mails dans Hotmail ! Créez un compte Hotmail, c'est gratuit !