compile function shr(x,n) Declare function toInt x = toInt(x) If n = 0 then return x mask = toint(2147483647) MsbMask = toint(-2147483648) for i = 1 to n *check if the msb is set msbSet = bitand(msbMask,x) ne 0 *reset the MSB x = int(bitand(mask,x)/2) *if the msb was on then set the 2nd most significant bit *where it would have moved to If msbSet then x = x + 1073741824 Next i Return x