[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Some thoughts on integer exponentiation (and an implementation)
- From: Sean Conner <sean@...>
- Date: Mon, 15 May 2017 05:20:27 -0400
It was thus said that the Great Oliver Kroth once stated:
> > I'm still confused. Ignoring rotates (which rotate the bits) CPUs tend to
> >support two forms of shifting, an unsigned variant (where 0 is copied in for
> >right shifts) and a signed variant (where the sign bit is copied for right
> >shifts) and are (nominally) used for multiplication/division by 2, which
> >makes it an arithmetic operation, and which I use to replace certain
> >exponential operations I used from Lua 5.1/5.2:
> > x = 2^30 -- Lua 5.1, 5.2 to get 1073741824
> > x = 1<<30 -- Lua 5.3 to get 1073741824
> > -spc
> the difference in unsigned and signed shifting exists only in
> right-shifts, where the sign bit, which is at the leftmost position, is
> either kept (signed) or filled with zero or carry bit (unsigned)
> On left-shifts no two versions are needed.
That, I get. What I'm replying to is Stefan Ginsberg's statement:
> I don't consider shifting out bits the same thing as overflow, it is
> another type of operation.
I don't---it's multiplication/division by 2 (in terms of overflow).