From 625f9c087e0212cbab4dc8761863214f8b701a19 Mon Sep 17 00:00:00 2001 From: Ulrich Meine Date: Sat, 29 Nov 2025 01:21:45 +0100 Subject: [PATCH] Fixed OBP60Formatter issue with speeds of 9.9999 knots --- lib/obp60task/OBP60Formatter.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/obp60task/OBP60Formatter.cpp b/lib/obp60task/OBP60Formatter.cpp index e4e73e0..8dcf50f 100644 --- a/lib/obp60task/OBP60Formatter.cpp +++ b/lib/obp60task/OBP60Formatter.cpp @@ -305,10 +305,13 @@ FormattedData formatValue(GwApi::BoatValue *value, CommonData &commondata){ snprintf(buffer, bsize, "%2.0f", speed); } else{ - if (speed < 10){ + speed = std::round(speed * 100) / 100; // in rare cases, speed could be 9.9999 kn instead of 10.0 kn + LOG_DEBUG(GwLog::DEBUG,"OBPFormatter-formatValue: value->value: %.3f speed: %.15f speed<10: %d", value->value, speed, speed < 10.0); + + if (speed < 10.0){ snprintf(buffer, bsize, fmt_dec_1, speed); } - else if (speed < 100){ + else if (speed < 100.0){ snprintf(buffer, bsize, fmt_dec_10, speed); } else {