From 3853df675a1e1db24950945f66b076266a7da409 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Thu, 9 Jul 2020 13:32:04 +0100 Subject: [PATCH] cheat in trunch_rem, truncate result of multiply --- src/nmutil/divmod.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- 2.30.2