Skip to content

Instantly share code, notes, and snippets.

@wszdwp
Last active December 23, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wszdwp/6663212 to your computer and use it in GitHub Desktop.
Save wszdwp/6663212 to your computer and use it in GitHub Desktop.
Cracking the interview 19.4
public class Question194
{
public static int getMax(int a, int b) {
int c = a - b;
int k = ( c >> 31) & 0x1;
return a - k * c;
}
public static void main(String[] args) {
int a = 5;
int b = 6;
System.out.println("Expected(6):" + getMax(a, b) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment