summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorS. Gilles <sgilles@math.umd.edu>2019-05-10 16:43:57 -0400
committerOri Bernstein <ori@eigenstate.org>2019-05-10 16:27:20 -0700
commitfd333ef7321e70c49b97d9ffb47805fe686e5d05 (patch)
treecae56182efbdee6c696a15a100cdbf3a23108b8a /lib
parentcec2ed10f355e59322f3d148837dca47aab083a6 (diff)
downloadmc-fd333ef7321e70c49b97d9ffb47805fe686e5d05.tar.gz
Allow exact case of mkbigint(2^32)
Diffstat (limited to 'lib')
-rw-r--r--lib/std/bigint.myr2
-rw-r--r--lib/std/test/bigint.myr6
2 files changed, 6 insertions, 2 deletions
diff --git a/lib/std/bigint.myr b/lib/std/bigint.myr
index 7b0f4bc..478d9fc 100644
--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -109,7 +109,7 @@ generic mkbigint = {v : @a :: integral,numeric @a
;;
val = (v : uint64)
slpush(&a.dig, (val : uint32))
- if val > Base
+ if val >= Base
slpush(&a.dig, (val/Base : uint32))
;;
-> trim(a)
diff --git a/lib/std/test/bigint.myr b/lib/std/test/bigint.myr
index 2467143..c87f1f3 100644
--- a/lib/std/test/bigint.myr
+++ b/lib/std/test/bigint.myr
@@ -27,7 +27,7 @@ const main = {
}
const smoketest = {ct
- var a, b, c, d, e
+ var a, b, c, d, e, f
var buf : byte[64], n
/* a few combined ops */
@@ -36,6 +36,7 @@ const smoketest = {ct
c = std.mkbigint(7919)
d = std.mkbigint(113051)
e = std.mkbigint(11)
+ f = std.mkbigint((4294967296 : int64))
std.bigmul(a, b)
std.bigmul(a, b)
@@ -50,6 +51,9 @@ const smoketest = {ct
n = std.bigbfmt(buf[:], a, 0)
testr.check(ct, std.eq(buf[:n], "517347321949036993306"), "simple smoke test failed")
+
+ n = std.bigbfmt(buf[:], f, 0)
+ testr.check(ct, std.eq(buf[:n], "4294967296"), "smoke test failed for 2^32 case")
}
const matchsmall = {c