Ref T215, PQ integer support

This commit is contained in:
Klaus Basan
2018-01-03 20:04:38 +01:00
parent 35af956c95
commit b2c0d726bc
2 changed files with 22 additions and 1 deletions

View File

@@ -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
{