[poincare/expression] Equalize simplified and approximate output in presence of units

This commit is contained in:
Ruben Dashyan
2020-01-21 13:44:31 +01:00
committed by Léa Saviot
parent c4f112e5aa
commit 054aac2c1c

View File

@@ -636,6 +636,14 @@ void Expression::beautifyAndApproximateScalar(Expression * simplifiedExpression,
*simplifiedExpression = deepBeautify(userReductionContext);
// Step 2: approximation
if (approximateExpression) {
if (simplifiedExpression->recursivelyMatches([](const Expression e, Context * context) { return e.type() == ExpressionNode::Type::Unit; }, nullptr, false)) {
/* Approximate and simplified expressions are set equal so that only
* one of them will be output. Note that there is no need to clone
* since the expressions will not be altered. */
*approximateExpression = *simplifiedExpression;
return;
}
*approximateExpression = simplifiedExpression->approximate<double>(context, complexFormat, angleUnit);
}
}