projects
/
nmutil.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
923551b
)
cheat in trunch_rem, truncate result of multiply
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Thu, 9 Jul 2020 12:32:04 +0000
(13:32 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Thu, 9 Jul 2020 12:32:04 +0000
(13:32 +0100)
src/nmutil/divmod.py
patch
|
blob
|
history
diff --git
a/src/nmutil/divmod.py
b/src/nmutil/divmod.py
index 0f1a5491aeaabb83eacb49e251c5ecedd6c4e94b..488e225ed7627fd9f44806a8de002b499448715b 100644
(file)
--- 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