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

Unified Diff: runtime/lib/bigint.dart

Issue 896393004: Add modPow(int exponent, int modulus) method to int abstract class. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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
===================================================================
--- runtime/lib/bigint.dart (revision 43571)
+++ runtime/lib/bigint.dart (working copy)
@@ -1338,10 +1338,13 @@
return other._toBigint()._compare(this) == 0;
}
- // Return pow(this, e) % m, with e >= 0, m > 0.
+ // Returns pow(this, e) % m, with e >= 0, m > 0.
int modPow(int e, int m) {
- if (e is! int || e < 0) throw new ArgumentError(e);
- if (m is! int || m <= 0) throw new ArgumentError(m);
+ if (e is! int) throw new ArgumentError(e);
+ if (m is! int) throw new ArgumentError(m);
+ if (e < 0) throw new RangeError(e);
+ if (m <= 0) throw new RangeError(m);
+ if (e == 0) return 1;
final m_used = m._used;
final m_used2p2 = 2*m_used + 1 + 1; // +1 for leading zero.
final e_bitlen = e.bitLength;
« 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