diff options
-rw-r--r-- | lib/std/bigint.myr | 2 | ||||
-rw-r--r-- | lib/std/test/bigint.myr | 6 |
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 |