repo.or.cz
/
libyakmo.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Parse negative numbers better
[libyakmo.git]
/
bigint.myr
blob
71eb0d9d3e7251cf4e268f211b83dae8899372e6
1
use std
2
3
use "traits"
4
5
pkg yakmo =
6
impl abs_struct std.bigint#
7
;;
8
9
impl abs_struct std.bigint# =
10
abs_ip = {b;
11
if !std.bigiszero(b)
12
b.sign = 1
13
;;
14
}
15
abs = {b;
16
var ret = std.bigdup(b)
17
abs_ip(ret)
18
-> ret
19
}
20
21
cmp_zero = {b;
22
if std.bigiszero(b)
23
-> `std.Equal
24
elif b.sign > 0
25
-> `std.After
26
else
27
-> `std.Before
28
;;
29
}
30
;;