Re: Rotating bits left in BASIC



druck wrote:
On 8 Sep 2006 Andrew Conroy <a.m.conroy@xxxxxxxxxxxx> wrote:
Moving on from here, I've now realised that the numbers I'm working with
are stupidly large and will be bigger than &7fffffff (in fact bigger than
&7fffffff*2), and so are, I guess, effectively 64bit numbers rather than
the more usual 32bit ones. This leads to two problems:
1) How do I rotate 64bit numbers?

You can do it in BASIC, but its nasty. This is a rotate right of 1 bit.

carry1% = highword% AND 1
carry2% = lowword% AND 1
highword% = (highword%>>>1) OR (carry2%<<31)
lowword% = (lowword%>>>1) OR (carry1%<<31)
Or:

temp% = highword%
highword% = (highword% >>> 1) OR (lowword% << 31)
lowword% = (lowword% >>> 1) OR (temp% << 31)

.