Advertisement
Guest User

New Wrap

a guest
Jul 30th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.19 KB | None | 0 0
  1. function wrap(n, l, u)
  2.  
  3. if l > u then ' Swap if bounds are backward
  4. t = l: l = u: u = t
  5. end if
  6.  
  7. p = n
  8.  
  9. p = p - l
  10. u = u - l
  11. p = p mod u
  12. if p < 0 then p = p + u
  13. wrap = p
  14.  
  15. end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement