diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 60f90babb..101540d2b 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -471,11 +471,14 @@ template Expression * Expression::approximate(Context& context, Angl } template T Expression::approximateToScalar(Context& context, AngleUnit angleUnit, ComplexFormat complexFormat) const { - Expression * evaluation = approximate(context, angleUnit, complexFormat); - T result = NAN; - if (evaluation->type() == Type::Decimal) { - result = static_cast(evaluation)->toScalar(); + if (angleUnit == AngleUnit::Default) { + angleUnit = Preferences::sharedPreferences()->angleUnit(); } + if (complexFormat == ComplexFormat::Default) { + complexFormat = Preferences::sharedPreferences()->complexFormat(); + } + Evaluation * evaluation = privateApproximate(T(), context, angleUnit); + T result = evaluation->toScalar(); /*if (evaluation->type() == Type::Matrix) { if (numberOfOperands() == 1) { result = static_cast *>(operand(0))->toScalar();