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

doubleabsCap(double value, double bounds)
Caps a value between -bounds to +bounds
return Math.min(Math.max(value, -bounds), bounds);
doubleabsClamp(double value, double bounds)
Clamps a value isBetween -bounds to +bounds
return min(max(value, -bounds), bounds);
doubleabsDegrees(double degrees)
abs Degrees
if (degrees < 0) {
    for (int i = (int) Math.round(degrees / -360); i >= 0; i--) {
        degrees += 360;
        ;
return degrees % 360;
doubleabsDelta(double a, double b)
abs Delta
if (a == b) {
    return 0.0;
if (Double.isNaN(a)) {
    return Double.isNaN(b) ? 0.0 : Double.POSITIVE_INFINITY;
} else if (Double.isNaN(b)) {
    return Double.POSITIVE_INFINITY;
return Math.abs(a - b);
floatabsDelta(float f1, float f2)
Compute the absolute value of the difference between two floating-point numbers having single precision.
double delta = f1 - f2;
return (float) ((delta < 0) ? delta * -1.0 : delta);
longabsDiff(long x, long y)
abs Diff
final long d = x - y;
if (d < 0)
    return d * -1;
return d;
intabsHash(Object obj)
abs Hash
return Math.abs(hash(obj));
intabsNeg(final int a)
abs Neg
return (a >> 31) - (a ^ a >> 31);
longabsNeg(long a)
abs Neg
return (a >> 63) - (a ^ (a >> 63));
floatabsNegativeZeros(float f)
If f is -0.0f, return 0.0f; otherwise, return f .
return f == 0.0f ? 0.0f : f;