Skip to content

Commit

Permalink
Simplify check for -0 in printNumber (#5581)
Browse files Browse the repository at this point in the history
  • Loading branch information
Connormiha authored and cpojer committed Feb 16, 2018
1 parent ba8a2d5 commit 0285e63
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions packages/pretty-format/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ function isToStringedArrayType(toStringed: string): boolean {
}

function printNumber(val: number): string {
if (val != +val) {
return 'NaN';
}
const isNegativeZero = val === 0 && 1 / val < 0;
return isNegativeZero ? '-0' : '' + val;
return Object.is(val, -0) ? '-0' : String(val);
}

function printFunction(val: Function, printFunctionName: boolean): string {
Expand Down

0 comments on commit 0285e63

Please sign in to comment.