Fun programming challenge

Geoff Canyon gcanyon at gmail.com
Mon Dec 7 10:30:42 EST 2015


On Mon, Dec 7, 2015 at 9:16 AM, Mark Waddingham <mark at livecode.com> wrote:

> Although it's important to remember that shift left by n bits is the same
> as multiplying by 2^n, and right is the same as div by 2^n. Rotate is a
> little trickier, admittedly.
>
> Mark
>

​Sure, I didn't say it was particularly difficult, just that it slowed me
down a bit (ha! pun!).

The values in question were limited to 16 bit, so my functions ended up as:

function rShift V,S
   return V div 2^S
end rShift

function lShift V,S
   return (V * 2^S) mod 65536
end lShift
​



More information about the use-livecode mailing list