ref: 36f4100dcea54700c0441a4667f601bcb5b1c59e
parent: c95732cc7a4f47740ace668693d4216d9482da1a
author: S. Gilles <sgilles@math.umd.edu>
date: Tue Feb 19 03:19:08 EST 2019
Allow bigparse to handle negative numbers
--- a/lib/std/bigint.myr
+++ b/lib/std/bigint.myr
@@ -234,7 +234,13 @@
var val : int, base
var v, b
var a
+ var s = 1
+ if hasprefix(str, "-")
+ s = -1
+ str = str[1:]
+ ;;
+
if hasprefix(str, "0x") || hasprefix(str, "0X")
base = 16
elif hasprefix(str, "0o") || hasprefix(str, "0O")
@@ -271,7 +277,7 @@
if val == 0
v.sign = 0
else
- v.sign = 1
+ v.sign = s
;;
bigmul(a, b)
bigadd(a, v)