Want more features on Pastebin? Sign Up, it's FREE!
Guest

shr

By: a guest on Aug 21st, 2012  |  syntax: None  |  size: 0.41 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data