Skip to content

Instantly share code, notes, and snippets.

@MarekVigas
Created November 8, 2018 10:31
Show Gist options
  • Save MarekVigas/d3eaa22c1e7437bec20c0f33d787f98f to your computer and use it in GitHub Desktop.
Save MarekVigas/d3eaa22c1e7437bec20c0f33d787f98f to your computer and use it in GitHub Desktop.
find max using bitwise operation
int findMax( int x, int y){
int z = x - y;
int i = (z >> 31) & 0x1;
int max = x - i * z;
return max;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment