From e4b59ddf69b7f9935f9b79061172bc5dcfb8592a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 17 Dec 2018 16:17:00 +0100 Subject: [PATCH] [poincare] Fix Expression::simplifyAndApproximate to display polar form of negative real expression. -5 --> 5*e^(i*Pi) --- poincare/src/expression.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 6b8b401e1..c3397080f 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -402,10 +402,10 @@ void Expression::simplifyAndApproximate(Expression * simplifiedExpression, Expre Expression e = deepReduce(context, angleUnit, ExpressionNode::ReductionTarget::User); *simplifiedExpression = Expression(); if (!sSimplificationHasBeenInterrupted) { - /* Case 1: the reduced expression is ComplexCartesian, we can take - * into account the complex format to display a+i*b or r*e^(i*th) */ - if (e.type() == ExpressionNode::Type::ComplexCartesian) { - ComplexCartesian ecomplex = static_cast(e); + /* Case 1: the reduced expression is ComplexCartesian or pure real, we can + * take into account the complex format to display a+i*b or r*e^(i*th) */ + if (e.type() == ExpressionNode::Type::ComplexCartesian || e.isReal(context, angleUnit)) { + ComplexCartesian ecomplex = e.type() == ExpressionNode::Type::ComplexCartesian ? static_cast(e) : ComplexCartesian::Builder(e, Rational(0)); if (approximateExpression) { /* Step 2: Approximation * We compute the approximate expression from the Cartesian form to avoid