diff options
| author | azidar | 2016-01-07 17:15:31 -0800 |
|---|---|---|
| committer | azidar | 2016-01-16 14:28:18 -0800 |
| commit | 4569194392122ae4715549b2f0b9fffff051b278 (patch) | |
| tree | ecd079cefa6fb69d1f8c75bc0e75e38599bc0da4 /src/main/stanza/bigint2.stanza | |
| parent | 2d583abda146dad8e0260928dcb19ad7136216b6 (diff) | |
Fixed a bunch of tests, and minor bugs
Diffstat (limited to 'src/main/stanza/bigint2.stanza')
| -rw-r--r-- | src/main/stanza/bigint2.stanza | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/main/stanza/bigint2.stanza b/src/main/stanza/bigint2.stanza index 91cd4558..deae1313 100644 --- a/src/main/stanza/bigint2.stanza +++ b/src/main/stanza/bigint2.stanza @@ -27,6 +27,10 @@ public defn to-int (x:Long) -> Int : if x > to-long(2147483647) or x < to-long(-2147483648) : error("Long too big to convert to Int") else : to-int(to-string(x)) +public defn to-int (x:BigInt) -> Int : + if length(d(x)) > 1 : error("BigInt too big to convert to Int") + else : d(x)[0] + public defn req-num-bits (i: Int) -> Int : val i* = if i < 0 : ((-1 * i) - 1) |
