feat: Add thousands separator to calculator output

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-03-14 14:42:43 -06:00
committed by Tanner
parent b86f6720bc
commit ca2265e8aa
+7 -1
View File
@@ -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);