fix: Ensure thousands separators display without premature scientific notation

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-03-14 15:17:25 -06:00
committed by Tanner
parent e57e09eb17
commit 5cb5ee604b
+7 -2
View File
@@ -252,9 +252,9 @@ function displayOutput(num) {
}
}
var numStr = num.toString();
var displayStr = addSeparators(numStr);
var displayStr;
if (typeof num === 'number' && (g.stringWidth(displayStr) > g.getWidth() - 20 || (num !== 0 && Math.abs(num) < 1e-4))) {
if (typeof num === 'number' && (g.stringWidth(numStr) > g.getWidth() - 20 || (num !== 0 && Math.abs(num) < 1e-4))) {
// try to format as scientific notation
let precision = 10; // start with high precision
while (precision >= 0) {
@@ -268,6 +268,11 @@ function displayOutput(num) {
if (precision < 0) { // if it still doesn't fit
displayStr = toExponential(num, 0).replace("e", "E");
}
} else {
displayStr = addSeparators(numStr);
if (g.stringWidth(displayStr) > g.getWidth() - 20) {
displayStr = numStr;
}
}
num = displayStr;