(long num)
| 59 | * @throws ArithmeticException if int-range overflows |
| 60 | */ |
| 61 | public static int safeCast(long num) { |
| 62 | |
| 63 | if (num < Integer.MIN_VALUE || num > Integer.MAX_VALUE) { |
| 64 | throw new ArithmeticException("Out of range: " + num); |
| 65 | } else { |
| 66 | return (int) num; |
| 67 | } |
| 68 | |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * <p>Sums up the numbers with range check. </p> |
no outgoing calls
no test coverage detected