Skip to content

Commit

Permalink
weather: Fix incorrect rounding for negative temperatures
Browse files Browse the repository at this point in the history
  • Loading branch information
FintasticMan committed Dec 9, 2024
1 parent d69cfcf commit 5705fad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/ble/SimpleWeatherService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5705fad

Please sign in to comment.