Skip to content

Instantly share code, notes, and snippets.

@davepkennedy
Created September 19, 2016 15:10
Show Gist options
  • Save davepkennedy/997f23d4b5e3c5730a606569963b48b4 to your computer and use it in GitHub Desktop.
Save davepkennedy/997f23d4b5e3c5730a606569963b48b4 to your computer and use it in GitHub Desktop.
Maximum of two numbers without a comparison
def max (a, b):
c = a-b
k = (c >> 31) & 1
return a - k * c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment