mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/multiplication] Fix handling of units with non-integer exponent
This commit is contained in:
committed by
Léa Saviot
parent
1c15f8fc58
commit
50f1ee9721
@@ -1091,7 +1091,20 @@ void Multiplication::splitIntoNormalForm(Expression & numerator, Expression & de
|
||||
Expression fd = factor.denominator(reductionContext);
|
||||
if (fd.isUninitialized()) {
|
||||
if (factor.childAtIndex(0).type() == ExpressionNode::Type::Unit) {
|
||||
factorsUnit = factor;
|
||||
/* A Unit should only have integer exponents, otherwise
|
||||
* simplification returns Undefined. That will be handled later in
|
||||
* Unit::shallowBeautify: since an Expression is beautified from
|
||||
* children to parent, the children of the current Multiplication are
|
||||
* not beautified yet and the exponent of a Unit is not guaranted at
|
||||
* this point to be an integer. Until then, any Unit with non-integer
|
||||
* exponent, is flushed into the numerator instead of units.
|
||||
*/
|
||||
Expression exponent = factor.childAtIndex(1);
|
||||
if (exponent.type() == ExpressionNode::Type::Rational && static_cast<Rational&>(exponent).isInteger()) {
|
||||
factorsUnit = factor;
|
||||
} else {
|
||||
factorsNumerator = factor;
|
||||
}
|
||||
} else {
|
||||
factorsNumerator = factor;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user