[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Some thoughts on integer exponentiation (and an implementation)
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sun, 14 May 2017 07:02:03 +0200
2017-05-13 22:16 GMT+02:00 Stefan Ginsberg <firstname.lastname@example.org>:
> 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
> 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
> 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'
Well, I raised a question much like this less than a year ago .
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.