summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-07-18 22:04:25 -0700
committerOri Bernstein <ori@eigenstate.org>2019-07-18 22:04:25 -0700
commit5de3c303dc818498a0c294440dbdf5890e6831f8 (patch)
treebddf707f766bc59723c0113a42785f5f5348d2ac /lib
parent820585fb7338092fa5b5001b81ad45b06376939d (diff)
downloadmc-5de3c303dc818498a0c294440dbdf5890e6831f8.tar.gz
Fix bigand/bigor: Thanks, Mike
Diffstat (limited to 'lib')
-rw-r--r--lib/std/bigint.myr10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/std/bigint.myr b/lib/std/bigint.myr
index 6e3d6d8..3f169a8 100644
--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -772,7 +772,13 @@ const bigdivmod = {a : bigint#, b : bigint# -> (bigint#, bigint#)
}
const bigand = {a, b
- for var i = 0; i < min(a.dig.len, b.dig.len); i++
+ if a.dig.len > b.dig.len
+ slzgrow(&b.dig, a.dig.len)
+ ;;
+ if b.dig.len > a.dig.len
+ slzgrow(&a.dig, b.dig.len)
+ ;;
+ for var i = 0; i < a.dig.len; i++
a.dig[i] &= b.dig[i]
;;
-> trim(a)
@@ -780,7 +786,7 @@ const bigand = {a, b
const bigor = {a, b
slzgrow(&a.dig, max(a.dig.len, b.dig.len))
- for var i = 0; i < a.dig.len; i++
+ for var i = 0; i < min(a.dig.len, b.dig.len); i++
a.dig[i] |= b.dig[i]
;;
-> trim(a)