Java Number Negate negateExact(double a)

Here you can find the source of negateExact(double a)

Description

Returns the negation of the argument, throwing an exception if the result exceeds a double .

License

Open Source License

Parameter

Parameter Description
a the value to negate

Exception

Parameter Description
ArithmeticException if the result overflows a double

Return

the result

Declaration

public static double negateExact(double a) 

Method Source Code

//package com.java2s;

public class Main {
    /**//ww w  .  j  av  a2  s .  c o  m
     * Returns the negation of the argument, throwing an exception if the result exceeds a {@code double}.
     *
     * @param a
     *          the value to negate
     * @return the result
     * @throws ArithmeticException
     *           if the result overflows a double
     */
    public static double negateExact(double a) {
        if (a == Double.MAX_VALUE || a == Double.MIN_VALUE) {
            throw new ArithmeticException("double overflow");
        }

        return -a;
    }
}

Related

  1. negate(int[] input)
  2. negate(int[] x, int Max)
  3. negate(String expr)
  4. negate(String string, String trueValue, String falseValue)
  5. negate(String value)
  6. negateExpression(String expression)
  7. negateInPlace(float[] in)
  8. Negation(String StartIP, String netmask)
  9. negative(float a)