[apps] Calculation: avoid 1/400000 = 0.000003

Re-serialise the calculation approximate output with the right number of
significant digits before comparing the parsed expression with the exact
one
This commit is contained in:
Émilie Feral
2018-01-29 18:29:13 +01:00
committed by EmilieNumworks
parent 03c8b373f7
commit ed59909531

View File

@@ -196,7 +196,10 @@ bool Calculation::exactAndApproximateOutputsAreEqual(Poincare::Context * context
if (exactOutput(context)->type() != Expression::Type::Rational) {
return false;
}
Expression * approximateOutput = Expression::ParseAndSimplify(m_approximateOutputText, *context);
assert(approximateOutput(context)->type() == Type::Complex);
char buffer[k_printedExpressionSize];
Complex<double>::convertFloatToText(static_cast<Complex<double> *>(approximateOutput(context))->a(), buffer, k_printedExpressionSize, Preferences::sharedPreferences()->numberOfSignificantDigits(), Preferences::sharedPreferences()->displayMode());
Expression * approximateOutput = Expression::ParseAndSimplify(buffer, *context);
bool isEqual = approximateOutput->isIdenticalTo(exactOutput(context));
delete approximateOutput;
return isEqual;