lua-users home
lua-l archive

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


On 16/01/2015 21.49, Roberto Ierusalimschy wrote:
You are missing the last sentence that you quoted!  "Then, the resulting
number is converted to the required type (float or integer) according
to the previous rules." The "required type" in this case is a float, as
explained in the rule for addition (Section 3.4.1):

   [...] the arithmetic operators work as follows: If both operands are
   integers, the operation is performed over integers and the result is an
   integer. Otherwise, if both operands are numbers or strings that can be
   converted to numbers (see §3.4.3), then they are converted to floats,
   [...]

Unary minus seems to behave the same way, which is coherent but not especially intuitive:

> "3"
3

> "-3"
-3

> -"3"
-3.0

I confess I had had no time to touch Lua in the past months (which is a pity) but I get the impression that the added efficiency and usefulness (at least for embedded systems) of the integer/float dualism may have come at some cost on the simplicity side, especially for unskilled users such as (some) game scripters and CS learners.
Maybe I only need to approach it the right way.

That said, I welcome Lua 5.3 :-)

P.S. Just compiled it with :
- Code::Blocks (mingw32-gcc) under 32-bit Windows XP.
- Xubuntu 32-bit (3.13.0-43-generic) with libreadline-dev.
No problems.

--
  Enrico