MathHelper.abs

Returns the absolute value of a {@code float} 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 float} with the same exponent and significand as the argument but with a guaranteed zero sign bit indicating a positive value:<br> {@code Float.intBitsToFloat(0x7fffffff & Float.floatToRawIntBits(a))}

@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)
    class MathHelper
    static
    float
    abs
    (
    float a
    )
  4. double abs(double a)

Meta