Index: third_party/google_input_tools/third_party/closure_library/closure/goog/math/math.js |
diff --git a/third_party/google_input_tools/third_party/closure_library/closure/goog/math/math.js b/third_party/google_input_tools/third_party/closure_library/closure/goog/math/math.js |
index ba789dc8856661e0177f54dd1d2eb64ad7c2bfe6..fe3def1693101ef3c875bcce759fb294dce57a96 100644 |
--- a/third_party/google_input_tools/third_party/closure_library/closure/goog/math/math.js |
+++ b/third_party/google_input_tools/third_party/closure_library/closure/goog/math/math.js |
@@ -217,10 +217,17 @@ goog.math.angleDifference = function(startAngle, endAngle) { |
/** |
* Returns the sign of a number as per the "sign" or "signum" function. |
* @param {number} x The number to take the sign of. |
- * @return {number} -1 when negative, 1 when positive, 0 when 0. |
+ * @return {number} -1 when negative, 1 when positive, 0 when 0. Preserves |
+ * signed zeros and NaN. |
*/ |
-goog.math.sign = function(x) { |
- return x == 0 ? 0 : (x < 0 ? -1 : 1); |
+goog.math.sign = Math.sign || function(x) { |
+ if (x > 0) { |
+ return 1; |
+ } |
+ if (x < 0) { |
+ return -1; |
+ } |
+ return x; // Preserves signed zeros and NaN. |
}; |
@@ -230,8 +237,8 @@ goog.math.sign = function(x) { |
* |
* Returns the longest possible array that is subarray of both of given arrays. |
* |
- * @param {Array.<Object>} array1 First array of objects. |
- * @param {Array.<Object>} array2 Second array of objects. |
+ * @param {Array<Object>} array1 First array of objects. |
+ * @param {Array<Object>} array2 Second array of objects. |
* @param {Function=} opt_compareFn Function that acts as a custom comparator |
* for the array ojects. Function should return true if objects are equal, |
* otherwise false. |
@@ -239,7 +246,7 @@ goog.math.sign = function(x) { |
* as a result subsequence. It accepts 2 arguments: index of common element |
* in the first array and index in the second. The default function returns |
* element from the first array. |
- * @return {!Array.<Object>} A list of objects that are common to both arrays |
+ * @return {!Array<Object>} A list of objects that are common to both arrays |
* such that there is no common subsequence with size greater than the |
* length of the list. |
*/ |
@@ -383,6 +390,15 @@ goog.math.isFiniteNumber = function(num) { |
/** |
+ * @param {number} num The number to test. |
+ * @return {boolean} Whether it is negative zero. |
+ */ |
+goog.math.isNegativeZero = function(num) { |
+ return num == 0 && 1 / num < 0; |
+}; |
+ |
+ |
+/** |
* Returns the precise value of floor(log10(num)). |
* Simpler implementations didn't work because of floating point rounding |
* errors. For example |