mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-27 17:50:04 +01:00
[poincare] Unit::chooseBestMultipleForValue handles edge cases (inf, 1,
0) cases itself
This commit is contained in:
@@ -440,7 +440,7 @@ Expression Multiplication::shallowBeautify(ExpressionNode::ReductionContext redu
|
||||
result = Undefined::Builder();
|
||||
} else {
|
||||
// Find the right unit prefix when the value ≠ 0
|
||||
if (unitConversionMode == ExpressionNode::UnitConversion::Default && value != 0.0 && value != 1.0 && !std::isinf(value)) {
|
||||
if (unitConversionMode == ExpressionNode::UnitConversion::Default) {
|
||||
// Identify the first Unit factor and its exponent
|
||||
Expression firstFactor = units;
|
||||
int exponent = 1;
|
||||
|
||||
@@ -319,7 +319,10 @@ Expression Unit::shallowReduce(ExpressionNode::ReductionContext reductionContext
|
||||
}
|
||||
|
||||
void Unit::chooseBestMultipleForValue(double & value, const int exponent, ExpressionNode::ReductionContext reductionContext) {
|
||||
assert(value != 0 && !std::isnan(value) && !std::isinf(value) && exponent != 0);
|
||||
assert(!std::isnan(value) && exponent != 0);
|
||||
if (value == 0 || value == 1.0 || std::isinf(value)) {
|
||||
return;
|
||||
}
|
||||
UnitNode * unitNode = node();
|
||||
const Dimension * dim = unitNode->dimension();
|
||||
/* Find in the Dimension 'dim' which unit (Representative and Prefix) make
|
||||
|
||||
Reference in New Issue
Block a user