Java Abs absNeg(long a)

Here you can find the source of absNeg(long a)

Description

abs Neg

License

Apache License

Return

The negative of the absolute value (always exact).

Declaration

static long absNeg(long a) 

Method Source Code

//package com.java2s;
/*// w ww.  ja va 2  s  . co  m
 * Copyright 2014 Jeff Hain
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

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

Related

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