interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / equiv / hexv.unit.om

65 lines · 1330 bytes Raw Blame History
1note irequiv fixture (issue 826): hex digit value, a real duplicate pair.
2note js_hexv (seed/json/json.om line 582) and hhexv (seed/net/http.om line 332)
3note are identical at omega-mv 62d1d0d6. Their ret ulong sub c K lines are each
4note split into d = sub c K / ret ulong d here, because omc IR mode at that
5note revision refuses a conversion of a computed operand (error 7, ir_cast).
6note hexfold is a refactor: one letter range after or c 32 folds case.
7note hexoff1 is a deliberate mutant (le c 70 became lt c 70): it differs
8note from the others at exactly one input, c = 70 ('F').
9fn js_hexv c uchar to ulong
10if and ge c 48 le c 57
11d = sub c 48
12ret ulong d
13end
14if and ge c 97 le c 102
15d = sub c 87
16ret ulong d
17end
18if and ge c 65 le c 70
19d = sub c 55
20ret ulong d
21end
22ret 16
23end
24fn hhexv c uchar to ulong
25if and ge c 48 le c 57
26d = sub c 48
27ret ulong d
28end
29if and ge c 97 le c 102
30d = sub c 87
31ret ulong d
32end
33if and ge c 65 le c 70
34d = sub c 55
35ret ulong d
36end
37ret 16
38end
39fn hexfold c uchar to ulong
40if and ge c 48 le c 57
41d = sub c 48
42ret ulong d
43end
44l = or c 32
45if and ge l 97 le l 102
46d = sub l 87
47ret ulong d
48end
49ret 16
50end
51fn hexoff1 c uchar to ulong
52if and ge c 48 le c 57
53d = sub c 48
54ret ulong d
55end
56if and ge c 97 le c 102
57d = sub c 87
58ret ulong d
59end
60if and ge c 65 lt c 70
61d = sub c 55
62ret ulong d
63end
64ret 16
65end