MathHelper.abs

Returns the absolute value of a {@code double} value. If the argument is not negative, the argument is returned. If the argument is negative, the negation of the argument is returned. Special cases: <ul><li>If the argument is positive zero or negative zero, the result is positive zero. <li>If the argument is infinite, the result is positive infinity. <li>If the argument is NaN, the result is NaN.</ul>

@apiNote As implied by the above, one valid implementation of this method is given by the expression below which computes a {@code double} with the same exponent and significand as the argument but with a guaranteed zero sign bit indicating a positive value:<br> {@code Double.longBitsToDouble((Double.doubleToRawLongBits(a)<<1)>>>1)}

@param a the argument whose absolute value is to be determined @return the absolute value of the argument.

  1. int abs(int a)
  2. long abs(long a)
  3. float abs(float a)
  4. double abs(double a)
    class MathHelper
    static
    double
    abs
    (
    double a
    )

Meta