Skip to content

Commit

Permalink
Fix implementation of Math.trunc
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Feb 2, 2015
1 parent 2153a23 commit c5dcee0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions math/trunc/shim.js
Expand Up @@ -6,8 +6,8 @@ module.exports = function (x) {
if (isNaN(x)) return NaN;
x = Number(x);
if (x === 0) return x;
if (x === Infinity) return 1;
if (x === -Infinity) return -1;
if (x === Infinity) return Infinity;
if (x === -Infinity) return -Infinity;
if (x > 0) return floor(x);
return -floor(-x);
};
4 changes: 2 additions & 2 deletions test/math/trunc/shim.js
Expand Up @@ -5,8 +5,8 @@ var is = require('../../../object/is');
module.exports = function (t, a) {
a(t({}), NaN, "NaN");
a(t(0), 0, "Zero");
a(t(Infinity), 1, "Infinity");
a(t(-Infinity), -1, "-Infinity");
a(t(Infinity), Infinity, "Infinity");
a(t(-Infinity), -Infinity, "-Infinity");
a(is(t(0.234), 0), true, "0");
a(is(t(-0.234), -0), true, "-0");
a(t(13.7), 13, "Positive #1");
Expand Down

0 comments on commit c5dcee0

Please sign in to comment.