From: Luke Kenneth Casson Leighton Date: Thu, 9 Jul 2020 12:32:04 +0000 (+0100) Subject: cheat in trunch_rem, truncate result of multiply X-Git-Tag: 24jan2021_ls180~40 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3853df675a1e1db24950945f66b076266a7da409;p=nmutil.git cheat in trunch_rem, truncate result of multiply --- diff --git a/src/nmutil/divmod.py b/src/nmutil/divmod.py index 0f1a549..488e225 100644 --- a/src/nmutil/divmod.py +++ b/src/nmutil/divmod.py @@ -15,6 +15,8 @@ def trunc_div(n, d): # this is a POWER ISA 3.0B compatible mod / remainder function # however it is also the c, c++, rust, java *and* x86 way of doing things def trunc_rem(n, d): - return n - d * trunc_div(n, d) + m = d * trunc_div(n, d) + m.bits = n.bits # cheat - really shouldn't do this. mul returns full length + return n - m