aboutsummaryrefslogtreecommitdiffstats
path: root/console/harness/numeric_conversion.js
diff options
context:
space:
mode:
authorDavid Fugate <dfugate@microsoft.com>2011-09-26 17:22:29 -0700
committerDavid Fugate <dfugate@microsoft.com>2011-09-26 17:22:29 -0700
commitbe82787a00f8b2de474e1bfb29d65d04af72255f (patch)
tree1acb1164cc571bfb134076e421209a32994f1363 /console/harness/numeric_conversion.js
parentffa85c258404e9808aa1595c1268593960f279d9 (diff)
Do not include 'code' key in test object metadata.
Diffstat (limited to 'console/harness/numeric_conversion.js')
-rw-r--r--console/harness/numeric_conversion.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/console/harness/numeric_conversion.js b/console/harness/numeric_conversion.js
new file mode 100644
index 000000000..427eeaa21
--- /dev/null
+++ b/console/harness/numeric_conversion.js
@@ -0,0 +1,21 @@
+// Copyright 2009 the Sputnik authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+function ToInteger(p) {
+ x = Number(p);
+
+ if(isNaN(x)){
+ return +0;
+ }
+
+ if((x === +0)
+ || (x === -0)
+ || (x === Number.POSITIVE_INFINITY)
+ || (x === Number.NEGATIVE_INFINITY)){
+ return x;
+ }
+
+ var sign = ( x < 0 ) ? -1 : 1;
+
+ return (sign*Math.floor(Math.abs(x)));
+}