diff --git a/src/blackgui/components/altitudedialog.cpp b/src/blackgui/components/altitudedialog.cpp index 41b8f5dcf..668ade3be 100644 --- a/src/blackgui/components/altitudedialog.cpp +++ b/src/blackgui/components/altitudedialog.cpp @@ -146,7 +146,7 @@ namespace BlackGui { if (mode == AltitudeInMetersConvertedToFeet) { - m_altitude = m_altitude.roundedToNearest100ft(); + m_altitude = m_altitude.roundedToNearest100ft(true); m_altitudeStr = m_altitude.valueRoundedWithUnit(0); } diff --git a/src/blackmisc/aviation/altitude.cpp b/src/blackmisc/aviation/altitude.cpp index 1125e419b..48505819c 100644 --- a/src/blackmisc/aviation/altitude.cpp +++ b/src/blackmisc/aviation/altitude.cpp @@ -341,7 +341,7 @@ namespace BlackMisc // the M/A formats are not supported by VATSIM, means by other clients // as feed, as none of the other clients - const CAltitude a = this->roundedToNearest100ft(); + const CAltitude a = this->roundedToNearest100ft(false); return a.valueRoundedWithUnit(CLengthUnit::ft(), 0); } @@ -378,12 +378,12 @@ namespace BlackMisc return CLength::compare(*this, otherAltitude); } - CAltitude CAltitude::roundedToNearest100ft() const + CAltitude CAltitude::roundedToNearest100ft(bool roundDown) const { // 23453 => 234.53 CAltitude a = this->switchedUnit(CLengthUnit::ft()); const double ft = a.value(CLengthUnit::ft()) / 100.0; - const int ftR = qRound(ft) * 100; + const int ftR = roundDown ? static_cast(floor(ft)) * 100 : qRound(ft) * 100; a.setValueSameUnit(ftR); return a; } diff --git a/src/blackmisc/aviation/altitude.h b/src/blackmisc/aviation/altitude.h index 91354d978..2c3f1c27f 100644 --- a/src/blackmisc/aviation/altitude.h +++ b/src/blackmisc/aviation/altitude.h @@ -194,7 +194,7 @@ namespace BlackMisc //! Round to the nearest 100ft, like needed for China and Russia //! \remark https://en.wikipedia.org/wiki/Flight_level - CAltitude roundedToNearest100ft() const; + CAltitude roundedToNearest100ft(bool roundDown) const; //! Null altitude (MSL) static const CAltitude &null();