From 2e6f2746164419657d210ede0bddf93fb9bd1021 Mon Sep 17 00:00:00 2001 From: David Bower Date: Fri, 19 Dec 2025 10:59:21 +0000 Subject: [PATCH] Fix display of model total cost to show whole dollar value or with two decimal place cent value. --- index.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index 01e8047..b1175a4 100644 --- a/index.html +++ b/index.html @@ -495,13 +495,15 @@

Model prices (per million tokens)

} function formatCost(totalCost) { - const dollars = trimZeros(totalCost.toFixed(6)); - if (totalCost >= 1) { - return `$${dollars}`; - } else { - const cents = trimZeros((totalCost * 100).toFixed(4)); - return `$${dollars} (${cents} cents)`; + // Show whole dollar amounts without decimals (e.g. $60) + // and amounts with cents with two decimal places (e.g. $3.20, $0.05). + if (!isFinite(totalCost) || isNaN(totalCost)) return '$0'; + const rounded = Math.round(totalCost); + // Treat values very close to integers as integers to avoid floating point noise + if (Math.abs(totalCost - rounded) < 1e-9) { + return `$${rounded}`; } + return `$${totalCost.toFixed(2)}`; } function setPreset(modelKey) {