From ac64b3ed22abd663cc22282adc2aeec076238201 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sat, 25 Apr 2026 16:30:19 -0500 Subject: [PATCH] fix(Utils): formatFrequency method to handle non-finite values and improve frequency formatting --- meshchatx/src/frontend/js/Utils.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/meshchatx/src/frontend/js/Utils.js b/meshchatx/src/frontend/js/Utils.js index f14684a..c6e42b2 100644 --- a/meshchatx/src/frontend/js/Utils.js +++ b/meshchatx/src/frontend/js/Utils.js @@ -204,15 +204,17 @@ class Utils { } static formatFrequency(hz) { - if (!hz || hz <= 0) { + const n = Number(hz); + if (!Number.isFinite(n) || n <= 0) { return "0 Hz"; } const k = 1000; + const rounded = Math.round(n); const sizes = ["Hz", "kHz", "MHz", "GHz", "THz", "PHz", "EHz", "ZHz", "YHz"]; - const i = Math.floor(Math.log(hz) / Math.log(k)); + const i = Math.floor(Math.log(rounded) / Math.log(k)); - return parseFloat(hz / Math.pow(k, i)) + " " + sizes[i]; + return parseFloat((rounded / Math.pow(k, i)).toFixed(6)) + " " + sizes[i]; } static decodeBase64ToUtf8String(base64) {