interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / drafts / rosettacode / binary-digits.wiki

49 lines · 892 bytes Raw Blame History
1=={{header|Omegese}}==
2{{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text nl "\n"
7note emit writes every byte of a to stdout; a short write is retried, an error exits 1
8fn emit a view uchar * to void
9o = ulong 0
10while lt o len a bound 4096
11k = write 1 a o sub len a o
12if le k 0
13exit 1
14end
15o = add o ulong k
16end
17end
18fn bin n ulong to void
19d = new uchar 64 0
20i = ulong 64
21v = n
22while true bound 64
23i = sub i 1
24put d i uchar add and v 1 48
25v = shr v 1
26if eq v 0
27break
28end
29end
30emit part d i sub 64 i
31emit nl
32end
33fn main to int
34bin 0
35bin 5
36bin 50
37bin 9000
38bin 18446744073709551615
39ret 0
40end
41</syntaxhighlight>
42{{out}}
43<pre>
440
45101
46110010
4710001100101000
481111111111111111111111111111111111111111111111111111111111111111
49</pre>