Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Unified Diff: runtime/lib/bigint.dart

Issue 1211473002: Make int.gcd accept zero operands. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Address comment. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/integers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/bigint.dart
diff --git a/runtime/lib/bigint.dart b/runtime/lib/bigint.dart
index 7e508bff07daa2aedfefcbffc7247e71bcf8e030..a278595175f561f9ca58520a3162aafafb66ebae 100644
--- a/runtime/lib/bigint.dart
+++ b/runtime/lib/bigint.dart
@@ -1811,11 +1811,14 @@ class _Bigint extends _IntegerImplementation implements int {
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 (other == 0) {
+ return this.abs();
+ }
return _binaryGcd(this, other._toBigint(), false);
}
}
« no previous file with comments | « no previous file | runtime/lib/integers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698