From: yangguo@chromium.org Date: Wed, 27 Aug 2014 09:49:38 +0000 (+0000) Subject: Slightly simplify Math.sign and Math.trunc. X-Git-Tag: upstream/4.7.83~7338 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c49aa16fdf2be8aa32891fb5e82f29c83007c8f0;p=platform%2Fupstream%2Fv8.git Slightly simplify Math.sign and Math.trunc. R=svenpanne@chromium.org Review URL: https://codereview.chromium.org/504343005 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23440 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/math.js b/src/math.js index 00a507a..7ead7a8 100644 --- a/src/math.js +++ b/src/math.js @@ -173,8 +173,8 @@ function MathSign(x) { x = TO_NUMBER_INLINE(x); if (x > 0) return 1; if (x < 0) return -1; - if (x === 0) return x; - return NAN; + // -0, 0 or NaN. + return x; } // ES6 draft 09-27-13, section 20.2.2.34. @@ -182,8 +182,8 @@ function MathTrunc(x) { x = TO_NUMBER_INLINE(x); if (x > 0) return MathFloor(x); if (x < 0) return MathCeil(x); - if (x === 0) return x; - return NAN; + // -0, 0 or NaN. + return x; } // ES6 draft 09-27-13, section 20.2.2.30.