shithub: mc

Download patch

ref: fd333ef7321e70c49b97d9ffb47805fe686e5d05
parent: cec2ed10f355e59322f3d148837dca47aab083a6
author: S. Gilles <sgilles@math.umd.edu>
date: Fri May 10 12:43:57 EDT 2019

Allow exact case of mkbigint(2^32)

--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -109,7 +109,7 @@
 	;;
 	val = (v : uint64)
 	slpush(&a.dig, (val : uint32))
-	if val > Base
+	if val >= Base
 		slpush(&a.dig, (val/Base : uint32))
 	;;
 	-> trim(a)
--- a/lib/std/test/bigint.myr
+++ b/lib/std/test/bigint.myr
@@ -27,7 +27,7 @@
 }
 
 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 @@
 	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 @@
 
 	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