lua-users home
lua-l archive

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


On 4/13/14, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
>
> Lua 5.3 work 1 worked that way. We changed to follow a guideline that
> the type of the result of an operation should not depend on the *values*
> of the operands, only on their types. (Note that all other operators
> satisfy this rule; the division, in particular, always convert its
> arguments to floats.)

With math types this goal is hard to meet. To be consistent with the rule that
only types matter one would need separate types for positive and
negative integers
which would be quite un-Lua-like.

>
> As others pointed out already, integer exponentiation with full 64 bits
> is useful (not to mention that it is usually faster, too). To make 2^3
> an integer and 2^-3 a float breaks that guideline. But maybe that case
> is worth the break.

I think that the "principle of least surprise" would favor 2^-3 == 0.125

--Leo--