ref: f8707f1de15909e9efbc3cc68094b56a1395bed7
parent: dcccec157840ef6fd894712427f16560e5b128da
author: Ori Bernstein <[email protected]>
date: Sat Sep 6 18:19:01 EDT 2014
Fix generic bigint construction. We don't truncate and divide by zero anymore. Life is good.
--- a/libstd/bigint.myr
+++ b/libstd/bigint.myr
@@ -58,7 +58,6 @@
a = zalloc()
- a.dig = slalloc(1)
if v < 0
a.sign = -1
v = -v
@@ -65,10 +64,10 @@
elif v > 0
a.sign = 1
;;
- i = 0
- while v != 0
- a.dig[i++] = (v castto(uint32))
- v /= (Base castto(@a::(numeric,integral)))
+ i = v castto(uint64)
+ while i > 0
+ a.dig = slpush(a.dig, (i castto(uint32)))
+ i /= Base
;;
-> trim(a)
}