lua-users home
lua-l archive

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


2017-05-13 22:16 GMT+02:00 Stefan Ginsberg <stefanginsberg@gmail.com>:

> Unless a new operator ('**' anyone?) is made then something has to give.
>
> Moreover, one could claim that this error-behavior already exists in Lua.
> Both '1 // 0' and '1 %% 0' will raise errors instead of "promoting" the
> operation
> to float to represent inf or nan, so why should '10^-3' promote to float to
> represent a fraction?
>
> Also, it makes '^' behave consistent with an "integer-only" setting.
> Allowing '^'
> to work in such a setting was my motivation for implementing this to begin
> with,
> and '10^-3' behaving differently there is less than ideal.
>
> In my view, integer exponentiation shouldn't be too much of a hassle,
> if one is just explicit with the type of numbers used: '10.0^-3.0'
>
> Thoughts?

Well, I raised a question much like this less than a year ago [1].
The usual sort of list discussion followed and the matter was dropped.

What I wanted was that if M and N are integers, and M^N can be
represented exactly, the exponentiation operator should do that.

You're going a step further and say: if it overflows, let it overflow.

I'm trying to think of a plausible use case and can't. If we had unsigned
integers, I could.

[1] http://lua-users.org/lists/lua-l/2016-06/msg00077.html