List of utility methods to do Number Max Value
float | max(final float a, final float b) max return a > b ? a : b;
|
float | max(final float a, final float b, final float c) Returns the maximum value of three floats. return a > b ? a > c ? a : c : b > c ? b : c;
|
int | max(final int a, final int b) Return the greater of the two values. return (a >= b ? a : b);
|
int | max(final int a, final int b) Provides an unbranched version of max for POSITIVE ints, it does 7 operation instead of branching (which is somewhat slower, but it's mainly here for educational purposes) The original code can be found in: http://graphics.stanford.edu/~seander/bithacks.html#IntegerMinOrMax final int ab = a - b; return b & (ab >> 31) | a & (~ab >> 31); |
double | max(final Iterable extends Number> numbers) max double max = -Double.MAX_VALUE; for (final Number number : numbers) { final double value = number.doubleValue(); if (value > max) { max = value; return max; ... |
Double | max(final Iterable Retrieve the max element Double max = Double.NEGATIVE_INFINITY; for (final Double value : values) { if (max < value) { max = value; return max; |
NUMBER_TYPE | max(final NUMBER_TYPE n1, final NUMBER_TYPE n2) max if (n1 == null && n2 == null) { return null; } else if (n1 == null) { return n2; } else if (n2 == null) { return n1; final int compared = compareTo(n1, n2); ... |
NUMBER_TYPE | max(final NUMBER_TYPE number1, final NUMBER_TYPE number2) max if (number1 == null && number2 == null) { return null; } else if (number1 == null) { return number2; } else if (number2 == null) { return number1; } else if (number1.doubleValue() > number2.doubleValue()) { return number1; ... |
String | max(final String string1, final String string2) Returns the shortest string. if (string1 == null) { return string2; } else if (string2 == null) { return string1; return string1.length() > string2.length() ? string1 : string2; |
float | max(float a, float b) max return a > b ? a : b;
|