Skip to content

Commit e54b433

Browse files
shinnnMylesBorins
authored andcommitted
util: use ES2015+ Object.is to check negative zero
Use `Object.is` to check whether the value is negative zero or not. Ref: b3e4fc6 PR-URL: #11332 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Evan Lucas <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent e7b7d72 commit e54b433

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/util.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,8 @@ function formatValue(ctx, value, recurseTimes) {
598598

599599

600600
function formatNumber(ctx, value) {
601-
// Format -0 as '-0'. Strict equality won't distinguish 0 from -0,
602-
// so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 .
603-
if (value === 0 && 1 / value < 0)
601+
// Format -0 as '-0'. Strict equality won't distinguish 0 from -0.
602+
if (Object.is(value, -0))
604603
return ctx.stylize('-0', 'number');
605604
return ctx.stylize('' + value, 'number');
606605
}

0 commit comments

Comments
 (0)