Skip to content

Commit

Permalink
fix negative value cascading in unti schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
jriegel committed Dec 15, 2013
1 parent 9d21736 commit 73684a9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Base/UnitsSchemaImperial1.cpp
Expand Up @@ -55,7 +55,7 @@ using namespace Base;

QString UnitsSchemaImperial1::schemaTranslate(Base::Quantity quant,double &factor,QString &unitString)
{
double UnitValue = quant.getValue();
double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();
// for imperial user/programmer mind; UnitValue is in internal system, that means
// mm/kg/s. And all combined units have to be calculated from there!
Expand Down Expand Up @@ -115,5 +115,5 @@ QString UnitsSchemaImperial1::schemaTranslate(Base::Quantity quant,double &facto
unitString = quant.getUnit().getString();
factor = 1.0;
}
return QString::fromLatin1("%1 %2").arg(UnitValue / factor).arg(unitString);
return QString::fromLatin1("%1 %2").arg(quant.getValue() / factor).arg(unitString);
}
4 changes: 2 additions & 2 deletions src/Base/UnitsSchemaInternal.cpp
Expand Up @@ -36,7 +36,7 @@ using namespace Base;

QString UnitsSchemaInternal::schemaTranslate(Base::Quantity quant,double &factor,QString &unitString)
{
double UnitValue = quant.getValue();
double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();

// now do special treatment on all cases seams nececarry:
Expand Down Expand Up @@ -97,6 +97,6 @@ QString UnitsSchemaInternal::schemaTranslate(Base::Quantity quant,double &factor
unitString = quant.getUnit().getString();
factor = 1.0;
}
return QString::fromUtf8("%1 %2").arg(UnitValue / factor).arg(unitString);
return QString::fromUtf8("%1 %2").arg(quant.getValue() / factor).arg(unitString);
}

4 changes: 2 additions & 2 deletions src/Base/UnitsSchemaMKS.cpp
Expand Up @@ -36,7 +36,7 @@ using namespace Base;

QString UnitsSchemaMKS::schemaTranslate(Base::Quantity quant,double &factor,QString &unitString)
{
double UnitValue = quant.getValue();
double UnitValue = std::abs(quant.getValue());
Unit unit = quant.getUnit();

// now do special treatment on all cases seams nececarry:
Expand Down Expand Up @@ -92,5 +92,5 @@ QString UnitsSchemaMKS::schemaTranslate(Base::Quantity quant,double &factor,QStr
unitString = quant.getUnit().getString();
factor = 1.0;
}
return QString::fromUtf8("%1 %2").arg(UnitValue / factor).arg(unitString);
return QString::fromUtf8("%1 %2").arg(quant.getValue() / factor).arg(unitString);
}

0 comments on commit 73684a9

Please sign in to comment.