SHARE
TWEET

shr

a guest Aug 21st, 2012 29 Never
  1. compile function shr(x,n)
  2. Declare function toInt
  3.  
  4. x = toInt(x)
  5. If n = 0 then return x
  6.  
  7. mask = toint(2147483647)
  8. MsbMask = toint(-2147483648)
  9.  
  10. for i = 1 to n
  11. *check if the msb is set msbSet = bitand(msbMask,x) ne 0
  12.  
  13. *reset the MSB
  14. x = int(bitand(mask,x)/2)
  15.  
  16. *if the msb was on then set the 2nd most significant bit
  17. *where it would have moved to
  18. If msbSet then x = x + 1073741824
  19. Next i
  20. Return x
RAW Paste Data
Top