Skip to content

Commit

Permalink
fix overflow in #i_gcd
Browse files Browse the repository at this point in the history
  • Loading branch information
ahorek committed Nov 12, 2018
1 parent 0d06c0f commit 5c3c90c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/util/Numeric.java
Expand Up @@ -514,10 +514,10 @@ public static long i_gcd(long x, long y) {
if (x == Long.MIN_VALUE) {
if (y == Long.MIN_VALUE)
return x;
return 1 << Long.numberOfTrailingZeros(Math.abs(y));
return 1L << Long.numberOfTrailingZeros(Math.abs(y));
}
if (y == Long.MIN_VALUE) {
return 1 << Long.numberOfTrailingZeros(Math.abs(x));
return 1L << Long.numberOfTrailingZeros(Math.abs(x));
}

x = Math.abs(x);
Expand Down

0 comments on commit 5c3c90c

Please sign in to comment.