Advertisement
Guest User

shr

a guest
Aug 21st, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement