From a5cc9a3a7b2a78a3ead0f3a06032bc705c982a13 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Tue, 3 May 2022 12:55:21 -0400 Subject: [PATCH] fix: display output --- src/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index e9ff9d0..43cd1cf 100644 --- a/src/index.js +++ b/src/index.js @@ -239,14 +239,19 @@ let customToStringHandlerToGuesstimateSyntax = (node, options) => { } }; -let toPrecision2 = (f) => f.toPrecision(2).toString(); +let toPrecision2 = (f) => f.toPrecision(2); +let numToString = (x) => + x < 10 + ? toPrecision2(x).toLocaleString() + : BigInt(Math.round(toPrecision2(x))).toString(); + let toShortGuesstimateString = (node) => { if (isArgLognormal(node)) { let factors = getFactors(node); // print(node); // print(factors); let ninetyPercentCI = to90PercentCI(factors[0], factors[1]); - return `${toPrecision2(ninetyPercentCI[0])} to ${toPrecision2( + return `${numToString(ninetyPercentCI[0])} to ${numToString( ninetyPercentCI[1] )}`; } else {