mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[poincare] implement isRationalZero for other numbers
Change-Id: I40f61958f9e51adb376407b2a512097962979417
This commit is contained in:
committed by
Émilie Feral
parent
9d077c672d
commit
58114255e5
@@ -28,6 +28,7 @@ public:
|
||||
// Expression subclassing
|
||||
Type type() const override { return Type::BasedInteger; }
|
||||
Sign sign(Context * context) const override { return Sign::Positive; }
|
||||
bool isRationalZero() const override { return integer().isZero(); }
|
||||
|
||||
// Layout
|
||||
Layout createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
Type type() const override { return Type::Decimal; }
|
||||
Sign sign(Context * context) const override { return m_negative ? Sign::Negative : Sign::Positive; }
|
||||
Expression setSign(Sign s, ReductionContext reductionContext) override;
|
||||
bool isRationalZero() const override { return unsignedMantissa().isZero(); }
|
||||
|
||||
// Approximation
|
||||
Evaluation<float> approximate(SinglePrecision p, Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const override {
|
||||
|
||||
@@ -153,7 +153,7 @@ public:
|
||||
ExpressionNode::Sign sign(Context * context) const { return node()->sign(context); }
|
||||
bool isUndefined() const { return node()->type() == ExpressionNode::Type::Undefined || node()->type() == ExpressionNode::Type::Unreal; }
|
||||
bool isNumber() const { return node()->isNumber(); }
|
||||
bool isRationalZero() const;
|
||||
bool isRationalZero() const { return node()->isRationalZero(); }
|
||||
bool isRationalOne() const;
|
||||
bool isRandom() const { return node()->isRandom(); }
|
||||
bool isParameteredExpression() const { return node()->isParameteredExpression(); }
|
||||
|
||||
@@ -187,6 +187,7 @@ public:
|
||||
|
||||
virtual Sign sign(Context * context) const { return Sign::Unknown; }
|
||||
virtual bool isNumber() const { return false; }
|
||||
virtual bool isRationalZero() const { return false; }
|
||||
virtual bool isRandom() const { return false; }
|
||||
virtual bool isParameteredExpression() const { return false; }
|
||||
/* childAtIndexNeedsUserParentheses checks if parentheses are required by mathematical rules:
|
||||
|
||||
@@ -40,6 +40,7 @@ public:
|
||||
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;
|
||||
bool isRationalZero() const override { return m_value == 0.0; }
|
||||
|
||||
// Layout
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
bool isNegative() const { return m_negative; }
|
||||
void setNegative(bool negative) { m_negative = negative; }
|
||||
bool isInteger() const { return denominator().isOne(); }
|
||||
bool isRationalZero() const override { return isZero(); }
|
||||
|
||||
// TreeNode
|
||||
size_t size() const override;
|
||||
|
||||
@@ -79,10 +79,6 @@ Expression Expression::childAtIndex(int i) const {
|
||||
|
||||
/* Properties */
|
||||
|
||||
bool Expression::isRationalZero() const {
|
||||
return type() == ExpressionNode::Type::Rational && convert<const Rational>().isZero();
|
||||
}
|
||||
|
||||
bool Expression::isRationalOne() const {
|
||||
return type() == ExpressionNode::Type::Rational && convert<const Rational>().isOne();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user