Skip to content

Commit 3bdac54

Browse files
shinnnitaloacasas
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 5b5dca9 commit 3bdac54

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/util.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -604,9 +604,8 @@ function formatValue(ctx, value, recurseTimes) {
604604

605605

606606
function formatNumber(ctx, value) {
607-
// Format -0 as '-0'. Strict equality won't distinguish 0 from -0,
608-
// so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 .
609-
if (value === 0 && 1 / value < 0)
607+
// Format -0 as '-0'. Strict equality won't distinguish 0 from -0.
608+
if (Object.is(value, -0))
610609
return ctx.stylize('-0', 'number');
611610
return ctx.stylize('' + value, 'number');
612611
}

0 commit comments

Comments
 (0)