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

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

Issue 2640223002: Attach NTP to Chrome Home bottom sheet (Closed)
Patch Set: nits Created 3 years, 11 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
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 07ac76e1f36aabc00bc34b0f381f90daf50f87d2..77f90a7bed6b357111f9d65b895b6650d6ebdc41 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
@@ -9,6 +9,9 @@ package org.chromium.chrome.browser.util;
*/
public class MathUtils {
+ /** A minimum difference to use when comparing floats for equality. */
+ public static final float EPSILON = 0.001f;
+
private MathUtils() {}
/**
@@ -158,4 +161,14 @@ public class MathUtils {
public static int compareLongs(long lhs, long rhs) {
return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1);
}
+
+ /**
+ * Determine if two floats are equal.
+ * @param f1 The first float to compare.
+ * @param f2 The second float to compare.
+ * @return True if the floats are equal.
+ */
+ public static boolean areFloatsEqual(float f1, float f2) {
+ return Math.abs(f1 - f2) < MathUtils.EPSILON;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698