Chromium Code Reviews| Index: runtime/lib/integers.dart |
| diff --git a/runtime/lib/integers.dart b/runtime/lib/integers.dart |
| index 90c3cddce053d69f6ece17f83b23fefd2af74f31..42a94b2d242a494e39f20d1ebe7c147a28c561fd 100644 |
| --- a/runtime/lib/integers.dart |
| +++ b/runtime/lib/integers.dart |
| @@ -390,19 +390,17 @@ 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"); |
| - } |
| + if (this == 0) return other.abs(); |
| + if (other == 0) return this.abs(); |
|
regis
2015/07/06 15:08:11
Remove these 2 lines, since you check for zero bel
|
| 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); |