mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T215, PQ integer support
This commit is contained in:
@@ -318,10 +318,25 @@ namespace BlackMisc
|
||||
int CPhysicalQuantity<MU, PQ>::valueInteger(MU unit) const
|
||||
{
|
||||
Q_ASSERT_X(!unit.isNull(), Q_FUNC_INFO, "Cannot convert to null");
|
||||
double v = unit.roundValue(this->value(unit), 0);
|
||||
const double v = unit.roundValue(this->value(unit), 0);
|
||||
return static_cast<int>(v);
|
||||
}
|
||||
|
||||
template<class MU, class PQ>
|
||||
int CPhysicalQuantity<MU, PQ>::valueInteger() const
|
||||
{
|
||||
return this->valueInteger(m_unit);
|
||||
}
|
||||
|
||||
template<class MU, class PQ>
|
||||
bool CPhysicalQuantity<MU, PQ>::isInteger() const
|
||||
{
|
||||
if (this->isNull()) { return false; }
|
||||
|
||||
const double diff = std::abs(this->value() - this->valueInteger());
|
||||
return diff <= m_unit.getEpsilon();
|
||||
}
|
||||
|
||||
template <class MU, class PQ>
|
||||
double CPhysicalQuantity<MU, PQ>::valueRounded(int digits) const
|
||||
{
|
||||
|
||||
@@ -107,6 +107,12 @@ namespace BlackMisc
|
||||
//! As integer value
|
||||
int valueInteger(MU unit) const;
|
||||
|
||||
//! As integer value in current unit
|
||||
int valueInteger() const;
|
||||
|
||||
//! Is value an integer
|
||||
bool isInteger() const;
|
||||
|
||||
//! Rounded value in current unit
|
||||
//! \note default digits is CMeasurementUnit::getDisplayDigits
|
||||
double valueRounded(int digits = -1) const;
|
||||
|
||||
Reference in New Issue
Block a user