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:
@@ -261,11 +261,19 @@ function displayOutput(num) {
|
||||
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 '-'
|
||||
g.setFont('7x11Numeric7Seg', 2);
|
||||
if (num.length > RESULT_MAX_LEN) {
|
||||
num = num.substr(0, RESULT_MAX_LEN - 1)+'...';
|
||||
if (num.indexOf("E") < 0)
|
||||
num = num.substr(0, RESULT_MAX_LEN - 1)+'...';
|
||||
}
|
||||
}
|
||||
g.setFontAlign(1,0);
|
||||
|
||||
Reference in New Issue
Block a user