diff --git a/lib/util.js b/lib/util.js index 003b5e5b54073b..42861aaa5ae8aa 100644 --- a/lib/util.js +++ b/lib/util.js @@ -602,9 +602,8 @@ function formatValue(ctx, value, recurseTimes) { function formatNumber(ctx, value) { - // Format -0 as '-0'. Strict equality won't distinguish 0 from -0, - // so instead we use the fact that 1 / -0 < 0 whereas 1 / 0 > 0 . - if (value === 0 && 1 / value < 0) + // Format -0 as '-0'. Strict equality won't distinguish 0 from -0. + if (Object.is(value, -0)) return ctx.stylize('-0', 'number'); return ctx.stylize('' + value, 'number'); }