[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua 5.3: wrong coercion?
- From: Lorenzo Donati <lorenzodonatibz@...>
- Date: Fri, 16 Jan 2015 20:41:21 +0100
Hi all!
I just found something that seems odd in Lua 5.3.
According to sect 3.4.3 in the refman:
"The conversion from strings to numbers goes as follows: First, the
string is converted to an integer or a float, following its syntax and
the rules of the Lua lexer. (The string may have also leading and
trailing spaces and a sign.) Then, the resulting number is converted to
the required type (float or integer) according to the previous rules."
Thus if I have a string which is "42" it should be coerced to an
integer, since 42 is parsed as an integer constant by the lexer, whereas
I get:
print( 43, "42" + 1 ) --> 43 43.0
where it seems that the addition is a float addition, signaling that one
of the operands is float. Is this a bug, an error in the refman or maybe
something on my side (Windows 7-64, using 32bit executables compiled
with TDM-GCC 4.9.2 32 bit)? Am I missing something?
-- Lorenzo