feat: Add thousands separator to calculator output
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -194,6 +194,12 @@ function fixFloat(n) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addSeparators(s) {
|
||||||
|
var parts = s.split(".");
|
||||||
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, "'");
|
||||||
|
return parts.join(".");
|
||||||
|
}
|
||||||
|
|
||||||
function doMath(x, y, operator) {
|
function doMath(x, y, operator) {
|
||||||
x = parseFloat(x);
|
x = parseFloat(x);
|
||||||
y = parseFloat(y);
|
y = parseFloat(y);
|
||||||
@@ -258,7 +264,7 @@ function displayOutput(num) {
|
|||||||
if (precision < 0) precision = 0;
|
if (precision < 0) precision = 0;
|
||||||
num = toExponential(num, precision).replace("e", "E");
|
num = toExponential(num, precision).replace("e", "E");
|
||||||
} else {
|
} else {
|
||||||
num = numStr;
|
num = addSeparators(numStr);
|
||||||
}
|
}
|
||||||
if (num.charAt(0) === '-') {
|
if (num.charAt(0) === '-') {
|
||||||
num = '- ' + num.substr(1);
|
num = '- ' + num.substr(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user