Index: runtime/lib/integers.dart |
diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart |
index 90c3cddce053d69f6ece17f83b23fefd2af74f31..63f868bfdd23568c7431f4facfea3f895f1124d5 100644 |
--- a/runtime/lib/integers.dart |
+++ b/runtime/lib/integers.dart |
@@ -390,19 +390,15 @@ class _IntegerImplementation extends _Num { |
return _binaryGcd(m, t, true); |
} |
- // Returns gcd of abs(this) and abs(other), with this != 0 and other !=0. |
+ // Returns gcd of abs(this) and abs(other). |
int gcd(int other) { |
if (other is! int) { |
throw new ArgumentError.value(other, "other", "not an integer"); |
} |
- if (this == 0) { |
- throw new ArgumentError.value(this, "this", "must not be zero"); |
- } |
- if (other == 0) { |
- throw new ArgumentError.value(this, "other", "must not be zero"); |
- } |
int x = this.abs(); |
int y = other.abs(); |
+ if (x == 0) return y; |
+ if (y == 0) return x; |
if ((x == 1) || (y == 1)) return 1; |
if (other is _Bigint) { |
return _toBigint().gcd(other); |