projects
/
nmutil.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e1db07b
)
whoops trunc_div returning neg/neg result rather than abs/abs
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Thu, 9 Jul 2020 12:28:42 +0000
(13:28 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Thu, 9 Jul 2020 12:28:42 +0000
(13:28 +0100)
src/nmutil/divmod.py
patch
|
blob
|
history
diff --git
a/src/nmutil/divmod.py
b/src/nmutil/divmod.py
index 2dc3196e17919a687bd56d8d55d53f373781f897..0f1a5491aeaabb83eacb49e251c5ecedd6c4e94b 100644
(file)
--- a/
src/nmutil/divmod.py
+++ b/
src/nmutil/divmod.py
@@
-3,8
+3,11
@@
def trunc_div(n, d):
abs_n = abs(n)
abs_d = abs(d)
- abs_q = n // d
- if (n < 0) == (d < 0):
+ abs_q = abs_n // abs_d
+ #print ("trunc_div", n.value, d.value,
+ # abs_n.value, abs_d.value, abs_q.value,
+ # n == abs_n, d == abs_d)
+ if (n == abs_n) == (d == abs_d):
return abs_q
return -abs_q