The lua manual also states that one should NOT rely on the implicit conversion of a string to its numerical value, and suggests the systematic use of tonumber().
Alan
On Thu, 9 Aug 2018 21:20:54 +0200
Pablo Rodriguez
On 08/09/2018 08:12 PM, Wolfgang Schuster wrote:
Use tonumber.
Many thanks for your reply, Wolfgang.
The issue is in Lua itself:
print(5+"5")
In versions prior to 5.3, result is "10".
From version 5.3, result is "10.0",
I would say this might be a bug. According to the “Lua 5.3 Reference Manual" (https://www.lua.org/manual/5.3/manual.html#3.1):
A numeric constant with a radix point or an exponent denotes a float; otherwise, if its value fits in an integer, it denotes an integer.
Well, "10.0" contains the radix point, but with no arithmetical relevance.
My background is in humanities and I don’t understand the exponent for being a float ("10²" contains an exponent [https://www.m-w.com/dictionary/exponent], but I would say is an integer in all possible worlds [or all the worlds I know ]).
Could anyone explain me what am I missing here or confirm whether this is a bug?
Many thanks for your help,
Pablo