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; |
+ } |
} |