lua-users home
lua-l archive

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


On Sun, Apr 13, 2014 at 1:34 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> (I already had to change existing Lua code to get it running with
>> work2.) Wouldn't it be more logical, if exponentiation with negative
>> exponent would convert the base argument to float, similar to the
>> division case?
>
> 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.)
>
> 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.

What about the overflow case? What are your thoughts as a member of
the core Lua team -- should exponentiation in the overflow case return
an incorrect value, return a float value, or do something else?

/s/ Adam