Created
June 7, 2020 11:01
-
-
Save logbasex/582057188c264e8e6437b3ebf34bb114 to your computer and use it in GitHub Desktop.
.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int getLargerNumber(int a, int b) { | |
int c = a - b; | |
//get sign bit's value | |
int k = (c >> 31) & 0x1; | |
return a - k * c; | |
} | |
public static void main(String[] args) { | |
//-------------------------------- | |
int[] seq = new int[]{0, 3, 2, 6, 20, 5, 4}; | |
int max = 0; | |
for (Integer i : seq) { | |
max = getLargerNumber(i, max); | |
} | |
System.out.println(max); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment