Skip to content

Commit 32bd37c

Browse files
committed
fixing exception
1 parent 97a5a8d commit 32bd37c

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/main/java/com/thealgorithms/bitmanipulation/BitwiseGCD.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ public static long gcd(long a, long b) {
5151
if (a == Long.MIN_VALUE || b == Long.MIN_VALUE) {
5252
// Delegate to BigInteger and try to return a long if it fits
5353
BigInteger g = gcdBig(BigInteger.valueOf(a), BigInteger.valueOf(b));
54-
try {
55-
return g.longValueExact();
56-
} catch (ArithmeticException ex) {
57-
throw new ArithmeticException("GCD doesn't fit into signed long. Use gcdBig() for full-range result.");
58-
}
54+
return g.longValueExact();
5955
}
6056

6157
// Work with non-negative long values now (safe because we excluded Long.MIN_VALUE)

0 commit comments

Comments
 (0)