Base: Units: introduce unit one

Dimensionless quantities have all exponents equal to zero.
Such quantities are simply numbers. The associated unit is
the unit one, symbol 1, although this is rarely explicitly
written.

See chapter 2.3.3 Dimensions of quantities, The International
System of Units, 9th edition.
This commit is contained in:
Ladislav Michl
2025-04-10 19:15:02 +02:00
parent 1c955c9347
commit f8d2789a43
10 changed files with 21 additions and 22 deletions

View File

@@ -281,11 +281,6 @@ int Unit::angle() const
return sig.Angle;
}
bool Unit::isEmpty() const
{
return Val == 0;
}
int Unit::operator [](int index) const
{
UnitSignature sig;
@@ -318,6 +313,11 @@ bool Unit::operator ==(const Unit& that) const
return Val == that.Val;
}
bool Unit::operator !=(const Unit& that) const
{
return Val != that.Val;
}
Unit Unit::operator *(const Unit &right) const
{
Unit result;
@@ -360,7 +360,7 @@ Unit Unit::operator /(const Unit &right) const
std::string Unit::getString() const
{
if (isEmpty()) {
if (Val == 0) {
return {};
}
@@ -658,6 +658,8 @@ std::string Unit::getTypeString() const
return spec->second;
}
const Unit Unit::One (0, 0, 0, 0, 0, 0, 0, 0);
// SI base units
const Unit Unit::AmountOfSubstance (0, 0, 0, 0, 0, 1);
const Unit Unit::ElectricCurrent (0, 0, 0, 1);