mirror of
https://github.com/c3d/DB48X-on-DM42.git
synced 2024-09-28 03:20:53 +02:00
units: Keep power integral
When we compute powers for units with numerical results on, we may end up with decimal powers in units for no reason. Spotted by displaying the result of an `EvalEq` with `FIX 2`. Fixes: #1086 Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
parent
4ecde93aaa
commit
631fa8f6f3
2 changed files with 2 additions and 0 deletions
|
@ -1260,6 +1260,7 @@ algebraic_p expression::simplify_products() const
|
|||
|
||||
// Save auto-simplify and set it, and evaluate units normally
|
||||
settings::SaveAutoSimplify sas(true);
|
||||
settings::SaveNumericalResults snr(false);
|
||||
save<bool> smode(unit::mode, false);
|
||||
save<bool> sexpr(unit::factoring, true);
|
||||
|
||||
|
|
|
@ -205,6 +205,7 @@ algebraic_p function::evaluate(algebraic_r xr, id op, ops_t ops)
|
|||
uint divisor = 2 + (op == ID_cbrt);
|
||||
algebraic_g exponent = +fraction::make(integer::make(1),
|
||||
integer::make(divisor));
|
||||
settings::SaveNumericalResults snr(false);
|
||||
uexpr = pow(uexpr, exponent);
|
||||
return unit::make(value, uexpr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue