mirror of
https://gitlab.com/c3d/db48x.git
synced 2024-09-29 05:36:58 +02:00
arithmetic: Truncate binary operations on based numbers
When the wordsize is small enough that we can operate with native results, we should truncate according to the word size, not truncate to 64 bits. Fixes: #624 Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
parent
94d4f16ac8
commit
aa1ba7c7d1
1 changed files with 6 additions and 1 deletions
|
@ -1210,12 +1210,17 @@ algebraic_p arithmetic::evaluate(id op,
|
|||
// Perform conversion of integer values to the same base
|
||||
integer_p xi = integer_p(object_p(x.Safe()));
|
||||
integer_p yi = integer_p(object_p(y.Safe()));
|
||||
if (xi->native() && yi->native())
|
||||
uint ws = Settings.WordSize();
|
||||
if (xi->native() && yi->native() && (!is_based(xt) || ws < 64))
|
||||
{
|
||||
ularge xv = xi->value<ularge>();
|
||||
ularge yv = yi->value<ularge>();
|
||||
if (ops.integer_ok(xt, yt, xv, yv))
|
||||
{
|
||||
if (is_based(xt))
|
||||
xv &= (1UL << ws) - 1UL;
|
||||
return rt.make<integer>(xt, xv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue