mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare/expression_node] Added Double type
Float<float> and Float<double> used to share the same expression type
(Float), and the distinction was made by comparing their size. However,
due to padding, their size could be the same, leading to some issues :
- On the simulator, in Calculation, type 1_mm^3 and go to the
additional outputs. One of the results would be -0.0003081979_µm^3.
Change-Id: Ic8f9328bf462104776fbab636c34d0d152cd7e58
This commit is contained in:
committed by
Émilie Feral
parent
1e82d5012b
commit
891366c51d
@@ -30,6 +30,7 @@ public:
|
||||
Rational,
|
||||
BasedInteger,
|
||||
Decimal,
|
||||
Double,
|
||||
Float,
|
||||
Infinity,
|
||||
Multiplication,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -18,7 +18,7 @@ int FloatNode<T>::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<T> * other = static_cast<const FloatNode<T> *>(e);
|
||||
if (value() < other->value()) {
|
||||
return -1;
|
||||
|
||||
@@ -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<float>)) {
|
||||
return static_cast<const FloatNode<float> *>(this)->value();
|
||||
} else {
|
||||
assert(size() == sizeof(FloatNode<double>));
|
||||
return static_cast<const FloatNode<double> *>(this)->value();
|
||||
}
|
||||
return static_cast<const FloatNode<float> *>(this)->value();
|
||||
case Type::Double:
|
||||
return static_cast<const FloatNode<double> *>(this)->value();
|
||||
case Type::Rational:
|
||||
return static_cast<const RationalNode *>(this)->templatedApproximate<double>();
|
||||
case Type::BasedInteger:
|
||||
|
||||
Reference in New Issue
Block a user