fix: Display small and large numbers in scientific notation

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-03-14 13:52:16 -06:00
committed by Tanner
parent 6ac882699a
commit a714c57b2b
+9 -1
View File
@@ -261,10 +261,18 @@ function displayOutput(num) {
num = num.substr(1); num = num.substr(1);
} }
} }
num = num.toString(); var numStr = num.toString();
if (typeof num === 'number' && (numStr.length > RESULT_MAX_LEN || (num !== 0 && Math.abs(num) < 1e-4))) {
let precision = RESULT_MAX_LEN - 8;
if (precision < 0) precision = 0;
num = num.toExponential(precision).replace("e", "E");
} else {
num = numStr;
}
num = num.replace("-","- "); // fix padding for '-' num = num.replace("-","- "); // fix padding for '-'
g.setFont('7x11Numeric7Seg', 2); g.setFont('7x11Numeric7Seg', 2);
if (num.length > RESULT_MAX_LEN) { if (num.length > RESULT_MAX_LEN) {
if (num.indexOf("E") < 0)
num = num.substr(0, RESULT_MAX_LEN - 1)+'...'; num = num.substr(0, RESULT_MAX_LEN - 1)+'...';
} }
} }