Skip to content

Instantly share code, notes, and snippets.

@grauwoelfchen
Created March 11, 2013 16:36
Show Gist options
  • Save grauwoelfchen/5135531 to your computer and use it in GitHub Desktop.
Save grauwoelfchen/5135531 to your computer and use it in GitHub Desktop.
def shift_multi(x, y)
m = 0
while x > 1
if x.even?
y = (y << 1) # * 2
x = (x >> 1) # / 2
else
m += y
x -= 1
end
end
y += m
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment