diff --git a/poincare/include/poincare/expression_node.h b/poincare/include/poincare/expression_node.h index 79c6eaa88..853355a89 100644 --- a/poincare/include/poincare/expression_node.h +++ b/poincare/include/poincare/expression_node.h @@ -30,6 +30,7 @@ public: Rational, BasedInteger, Decimal, + Double, Float, Infinity, Multiplication, diff --git a/poincare/include/poincare/float.h b/poincare/include/poincare/float.h index 40f73ffed..400e3cc48 100644 --- a/poincare/include/poincare/float.h +++ b/poincare/include/poincare/float.h @@ -36,7 +36,7 @@ public: #endif // Properties - Type type() const override { return Type::Float; } + Type type() const override { return (sizeof(T) == sizeof(float)) ? Type::Float : Type::Double; } Sign sign(Context * context) const override { return m_value < 0 ? Sign::Negative : Sign::Positive; } Expression setSign(Sign s, ReductionContext reductionContext) override; int simplificationOrderSameType(const ExpressionNode * e, bool ascending, bool canBeInterrupted, bool ignoreParentheses) const override; diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 62592f10c..a9032a621 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -167,7 +167,7 @@ bool Expression::deepIsMatrix(Context * context) const { } bool Expression::IsApproximate(const Expression e, Context * context) { - return e.type() == ExpressionNode::Type::Decimal || e.type() == ExpressionNode::Type::Float; + return e.type() == ExpressionNode::Type::Decimal || e.type() == ExpressionNode::Type::Float || e.type() == ExpressionNode::Type::Double; } bool Expression::IsRandom(const Expression e, Context * context) { diff --git a/poincare/src/float.cpp b/poincare/src/float.cpp index cdfd918d7..f26af803d 100644 --- a/poincare/src/float.cpp +++ b/poincare/src/float.cpp @@ -18,7 +18,7 @@ int FloatNode::simplificationOrderSameType(const ExpressionNode * e, bool asc if (!ascending) { return e->simplificationOrderSameType(this, true, canBeInterrupted, ignoreParentheses); } - assert(e->type() == ExpressionNode::Type::Float); + assert((e->type() == ExpressionNode::Type::Float && sizeof(T) == sizeof(float)) || (e->type() == ExpressionNode::Type::Double && sizeof(T) == sizeof(double))); const FloatNode * other = static_cast *>(e); if (value() < other->value()) { return -1; diff --git a/poincare/src/number.cpp b/poincare/src/number.cpp index 0bbd1c252..32e4f58f2 100644 --- a/poincare/src/number.cpp +++ b/poincare/src/number.cpp @@ -25,12 +25,9 @@ double NumberNode::doubleApproximation() const { assert(Number(this).sign() == Sign::Negative || Number(this).sign() == Sign::Positive); return Number(this).sign() == Sign::Negative ? -INFINITY : INFINITY; case Type::Float: - if (size() == sizeof(FloatNode)) { - return static_cast *>(this)->value(); - } else { - assert(size() == sizeof(FloatNode)); - return static_cast *>(this)->value(); - } + return static_cast *>(this)->value(); + case Type::Double: + return static_cast *>(this)->value(); case Type::Rational: return static_cast(this)->templatedApproximate(); case Type::BasedInteger: