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:
@@ -252,9 +252,9 @@ function displayOutput(num) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var numStr = num.toString();
|
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
|
// try to format as scientific notation
|
||||||
let precision = 10; // start with high precision
|
let precision = 10; // start with high precision
|
||||||
while (precision >= 0) {
|
while (precision >= 0) {
|
||||||
@@ -268,6 +268,11 @@ function displayOutput(num) {
|
|||||||
if (precision < 0) { // if it still doesn't fit
|
if (precision < 0) { // if it still doesn't fit
|
||||||
displayStr = toExponential(num, 0).replace("e", "E");
|
displayStr = toExponential(num, 0).replace("e", "E");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
displayStr = addSeparators(numStr);
|
||||||
|
if (g.stringWidth(displayStr) > g.getWidth() - 20) {
|
||||||
|
displayStr = numStr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
num = displayStr;
|
num = displayStr;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user