Skip to content

Commit

Permalink
Oops, negative numbers were negative zero!
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed May 13, 2014
1 parent 99ef4ed commit 746cb97
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
@@ -1,6 +1,6 @@
"use strict";

module.exports = function isNegativeZero(value) {
return Infinity / Number(value) < 0;
return Number(value) === 0 && Infinity / Number(value) < 0;
};

1 change: 1 addition & 0 deletions test.js
Expand Up @@ -16,6 +16,7 @@ test('not negative zero', function (t) {
t.notOk(isNegativeZero([]), 'array is not negative zero');
t.notOk(isNegativeZero({}), 'object is not negative zero');
t.notOk(isNegativeZero(function () {}), 'function is not negative zero');
t.notOk(isNegativeZero(-1), '-1 is not negative zero');

t.end();
});
Expand Down

0 comments on commit 746cb97

Please sign in to comment.