From 5705fade2ebef601821870fecabe4357b8721b84 Mon Sep 17 00:00:00 2001 From: FintasticMan Date: Tue, 10 Dec 2024 00:11:13 +0100 Subject: [PATCH] weather: Fix incorrect rounding for negative temperatures --- src/components/ble/SimpleWeatherService.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/ble/SimpleWeatherService.h b/src/components/ble/SimpleWeatherService.h index 0f8c181bd3..501d434dcc 100644 --- a/src/components/ble/SimpleWeatherService.h +++ b/src/components/ble/SimpleWeatherService.h @@ -75,11 +75,13 @@ namespace Pinetime { } [[nodiscard]] int16_t Celsius() const { - return (PreciseCelsius() + 50) / 100; + int16_t temp = PreciseCelsius(); + return (temp + (temp >= 0 ? 50 : -50)) / 100; } [[nodiscard]] int16_t Fahrenheit() const { - return (PreciseFahrenheit() + 50) / 100; + int16_t temp = PreciseFahrenheit(); + return (temp + (temp >= 0 ? 50 : -50)) / 100; } bool operator==(const Temperature& other) const {