From 54f57cb1a01b1ef0c9f39b63c6500d2d8928b0a8 Mon Sep 17 00:00:00 2001 From: Zheyuan Wei Date: Tue, 19 Nov 2024 02:13:11 -0500 Subject: [PATCH] fix: precision error --- frontend/index.html | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index e28b643..9875a06 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -116,9 +116,15 @@ const value = parseFloat(input.value); if (key.includes("[")) { const [baseKey, index] = key.match(/(\w+)\[(\d+)\]/).slice(1); - saveData[baseKey][parseInt(index, 10)] = value; + if ( + Math.abs(saveData[baseKey][parseInt(index, 10)] - value) > + 0.0001 + ) { + saveData[baseKey][parseInt(index, 10)] = value; + } } else { - saveData[key] = value; + if (Math.abs(saveData[key] - value) > 0.0001) + saveData[key] = value; } });