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

Unified Diff: third_party/google_input_tools/third_party/closure_library/closure/goog/math/math.js

Issue 1257313003: Update Google Input Tools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Free up grd resources. Created 5 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
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

Powered by Google App Engine
This is Rietveld 408576698