Skip to content

Commit 0285e63

Browse files
Connormihacpojer
authored andcommitted
Simplify check for -0 in printNumber (#5581)
1 parent ba8a2d5 commit 0285e63

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

packages/pretty-format/src/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,7 @@ function isToStringedArrayType(toStringed: string): boolean {
8080
}
8181

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

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

0 commit comments

Comments
 (0)