Skip to content

Commit

Permalink
Remove is<Neg> logic from DivExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
Saymon committed Aug 13, 2023
1 parent 77d4b8c commit acf62b6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/fintamath/expressions/binary/DivExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ DivExpression::DivExpression(const ArgumentPtr &inLhsChild, const ArgumentPtr &i
}

std::string DivExpression::toString() const {
if (auto lhsChildExpr = cast<IExpression>(lhsChild); lhsChildExpr && is<Neg>(lhsChildExpr->getFunction())) {
ArgumentPtr innerDiv = makeExpr(Div(), lhsChildExpr->getChildren().front(), rhsChild);
if (auto lhsChildExpr = cast<IExpression>(lhsChild); lhsChildExpr && isNegative(lhsChildExpr)) {
ArgumentPtr innerDiv = makeExpr(Div(), makeExpr(Neg(), lhsChildExpr)->toMinimalObject(), rhsChild);
return makeExpr(Neg(), innerDiv)->toString();
}

Expand Down Expand Up @@ -386,17 +386,17 @@ ArgumentPtr DivExpression::powSimplify(const ArgumentPtr &lhs, const ArgumentPtr
ArgumentPtr lhsChild;
ArgumentPtr rhsChild;

if (const auto lhsExpr = cast<IExpression>(lhs); lhsExpr && is<Neg>(lhsExpr->getFunction())) {
if (const auto lhsExpr = cast<IExpression>(lhs); lhsExpr && isNegative(lhsExpr)) {
isResultNegated = !isResultNegated;
lhsChild = lhsExpr->getChildren().front();
lhsChild = makeExpr(Neg(), lhsExpr);
}
else {
lhsChild = lhs;
}

if (const auto rhsExpr = cast<IExpression>(rhs); rhsExpr && is<Neg>(rhsExpr->getFunction())) {
if (const auto rhsExpr = cast<IExpression>(rhs); rhsExpr && isNegative(rhsExpr)) {
isResultNegated = !isResultNegated;
rhsChild = rhsExpr->getChildren().front();
rhsChild = makeExpr(Neg(), rhsExpr);
}
else {
rhsChild = rhs;
Expand Down

0 comments on commit acf62b6

Please sign in to comment.