Fix rounding bug when displaying frequencies (#1801)

This commit is contained in:
Mark Thompson 2024-01-22 00:54:29 -06:00 committed by GitHub
parent ac1d350aaf
commit 0f85f247b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 4 deletions

View file

@ -498,12 +498,13 @@ void GeoMap::draw_scale(Painter& painter) {
if (m < 1000) {
km_string = to_string_dec_uint(m) + "m";
} else {
m += 50; // (add rounding factor for div by 100 below)
uint32_t km = m / 1000;
m -= km * 1000;
if (m == 0) {
km_string = to_string_dec_uint(km) + " km";
} else {
km_string = to_string_dec_uint(km) + "." + to_string_dec_uint((m + 50) / 100, 1) + "km";
km_string = to_string_dec_uint(km) + "." + to_string_dec_uint(m / 100, 1) + "km";
}
}