Shifting numbers in MMBasic


Author Message
crackerjack

Senior Member

Joined: 11/07/2011
Location: Australia
Posts: 164
Posted: 04:19am 08 Mar 2012      

In a word - yes.

I don't have the time for a full code example now, but essentially to LeftShift (<<) by 16 or 8 bytes, do this:

byte1 = (byte1 * (2 ^ 16)) And &hFFFF
byte2 = (byte2 * (2 ^ 8)) And &hFF
x = byte1 + byte2 + byte3

Then RightShift(>>) by 8-y bytes is:

x = x \ (2 ^ (8 - y))

Cheers,

crackerjack