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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java

Issue 394353003: [Android] Add positive modulo method in MathUtils class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java
index 5ff9b32d23734db5a7ba76ebe66bbf4965bf632b..01c116d576afe7d7cc16d3aae030c7bdc70f3804 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java
@@ -64,4 +64,13 @@ public class MathUtils {
else if (value > max) value = max;
return value;
}
+
+ /**
+ * Computes a%b that is positive. Note that result of % operation is not always positive.
+ * @return a%b >= 0 ? a%b : a%b + b
+ */
+ public static int positiveModulo(int a, int b) {
+ int mod = a % b;
+ return mod >= 0 ? mod : mod + b;
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698