Here you can find the source of negateExact(double a)
Parameter | Description |
---|---|
a | the value to negate |
Parameter | Description |
---|---|
ArithmeticException | if the result overflows a double |
public static double negateExact(double a)
//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; } }