Java Abs absNeg(final int a)

Here you can find the source of absNeg(final int a)

Description

abs Neg

License

Open Source License

Return

The negative of the absolute value (always exact).

Declaration

public static int absNeg(final int a) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from  w w  w .j ava 2 s . c  om
     * @return The negative of the absolute value (always exact).
     */
    public static int absNeg(final int a) {
        return (a >> 31) - (a ^ a >> 31);
    }

    /**
     * @return The negative of the absolute value (always exact).
     */
    public static long absNeg(final long a) {
        return (a >> 63) - (a ^ a >> 63);
    }
}

Related

  1. absDegrees(double degrees)
  2. absDelta(double a, double b)
  3. absDelta(float f1, float f2)
  4. absDiff(long x, long y)
  5. absHash(Object obj)
  6. absNeg(long a)
  7. absNegativeZeros(float f)
  8. Absolute(int a)