09-05-2022, 01:32 AM
(09-04-2022, 06:59 PM)bplus Wrote:(09-04-2022, 05:53 PM)OldMoses Wrote:(09-04-2022, 04:59 PM)bplus Wrote: Wow nice list of improvements. What is difference between shift left / right and rotate left /right?
shifts will drop bits from the end shifted toward. Rotate will carry those bits around to the opposite end.
Thanks, OK left and right shifts mult or divide by 2, what does rotate do?
I can recall, from back in the days when I attempted to fool with Assembly, that most CPU's had ROL & ROR in their instruction set. Also known as 'circular shifting' or 'rotate no carry'. However, I can't recall ever using it. The mathematics of doing it is pretty squirrely, and I can't for the life of me think of a mathematical application. I can't find much on the net about it, other than what it is. I found a mention on wikipedia that it is used frequently in cryptography. Not surprising given the arcane nature of that pursuit. I can imagine a simple encryption scheme of using a key array to rotate character bytes in certain order, to scramble them up and then reversing the order to unscramble them, but I'm sure its use is far more sophisticated than my kindergarden encryption ideas.
A lot of languages don't have native support for circular shifting, requiring the writing of appropriate functions, so now QB64PE has something to distinguish it from the rest of the rabble. Perhaps someone can discuss why it was added.
You can rotate 0 & -1 in either direction until the cows fly in to roost and they will remain 0 & -1, respectively.
It will act very much like _SHL & _SHR until a set bit crosses the MSB/LSB boundary and signs will flip (unless you're working with unsigned variables) and all sorts of weird fun commences.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
sha_na_na_na_na_na_na_na_na_na: