(int value)
| 337 | * @throws ArithmeticException if int-range overflows |
| 338 | */ |
| 339 | public static int safeNegate(int value) { |
| 340 | |
| 341 | if (value == Integer.MIN_VALUE) { |
| 342 | throw new ArithmeticException("Not negatable: " + value); |
| 343 | } else { |
| 344 | return -value; |
| 345 | } |
| 346 | |
| 347 | } |
| 348 | |
| 349 | /** |
| 350 | * <p>Inverts the number with range check. </p> |