Java Utililty Methods Abs

List of utility methods to do Abs

Description

The list of methods to do Abs are organized into topic(s).

Method

floatabs(float value)
abs
return value >= 0.0F ? value : -value;
float[]abs(float[] items)
abs
return abs(items, 0, items.length);
float[]abs(float[] values)
abs
for (int i = 0; i < values.length; i++)
    values[i] = Math.abs(values[i]);
return values;
intabs(int i)
Betrag der gegebenen Zahl.
return i < 0 ? -i : i;
intabs(int n)
Computes the absolute value of a number without branching
The original code can be found in: http://graphics.stanford.edu/~seander/bithacks.html#IntegerAbs
final int n31 = n >> 31;
return (n + n31) ^ n31;
intabs(int number)
return the absolute integer
return (number < 0) ? -number : number;
doubleabs(int pos, double[] array)
Computes the absolute value of the complex number at position pos in the array
return Math.sqrt(Math.pow(array[pos * 2], 2) + Math.pow(array[(2 * pos) + 1], 2));
intabs(int val)
abs
if (val >= 0)
    return val;
return val * -1;
intabs(int val)
abs
int sign = (val >> 31);
return (val ^ sign) - sign;
intabs(int value)
This method returns the absolute value of the provided value.
if (value < 0) {
    return -value;
return value;