mirror of
https://github.com/c3d/DB48X-on-DM42.git
synced 2024-09-28 03:20:53 +02:00
units: Simplify units that convert to real numbers
When we are given a value like `1_cm/in`, it is OK to pass it as input to the `sin` function or similar. Fixes: #1089 Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
parent
6699dd64bd
commit
5e43b5bba8
1 changed files with 9 additions and 3 deletions
|
@ -195,9 +195,9 @@ algebraic_p function::evaluate(algebraic_r xr, id op, ops_t ops)
|
|||
}
|
||||
|
||||
// Check if we need to deal with units specially
|
||||
if (op == ID_sqrt || op == ID_cbrt)
|
||||
if (unit_p u = x->as<unit>())
|
||||
{
|
||||
if (unit_p u = xr->as<unit>())
|
||||
if (op == ID_sqrt || op == ID_cbrt)
|
||||
{
|
||||
algebraic_g value = u->value();
|
||||
algebraic_g uexpr = u->uexpr();
|
||||
|
@ -209,7 +209,13 @@ algebraic_p function::evaluate(algebraic_r xr, id op, ops_t ops)
|
|||
uexpr = pow(uexpr, exponent);
|
||||
return unit::make(value, uexpr);
|
||||
}
|
||||
|
||||
save<bool> ueval(unit::mode, true);
|
||||
x = x->evaluate();
|
||||
if (x && x->type() == ID_unit)
|
||||
{
|
||||
rt.inconsistent_units_error();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert arguments to numeric if necessary
|
||||
|
|
Loading…
Reference in a new issue