lua-users home
lua-l archive

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


On Apr 28, 2014, at 7:14 AM, Leo Razoumov <slonik.az@gmail.com> wrote:

> 
>> 
>> 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--
> 

I think the principle of least surprise here is consistency. I’m with Roberto on this one, in that it should only be the types that affect the outcome. If you really wanted to be consistent, you would have ^ that coerced both values to float and ^^ that coerced both (or one??) to integer, mirroring the new model for division. This would also, interestingly, not break existing 5.2 code.

—Tim