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
omega-mv / gpu / nvidia / om / core / fmtnum.om
| 1 | note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | note Copyright 2026 Drake Stapleton |
| 3 | fn omnum bits ulong base ulong signed ulong buf edit uchar 24 to ulong |
| 4 | x = bits |
| 5 | minus = and ne signed 0 ge bits 9223372036854775808 |
| 6 | if minus |
| 7 | x = sub ulong 0 bits |
| 8 | end |
| 9 | tmp = new uchar 24 0 |
| 10 | n = ulong 0 |
| 11 | while ne x 0 bound 24 |
| 12 | r = rem x base |
| 13 | if lt r 10 |
| 14 | put tmp n uchar add r 48 |
| 15 | else |
| 16 | put tmp n uchar add r 87 |
| 17 | end |
| 18 | n = add n 1 |
| 19 | x = div x base |
| 20 | end |
| 21 | if eq n 0 |
| 22 | put tmp 0 uchar 48 |
| 23 | n = 1 |
| 24 | end |
| 25 | start = ulong 0 |
| 26 | if minus |
| 27 | put buf 0 uchar 45 |
| 28 | start = 1 |
| 29 | end |
| 30 | for i ulong n |
| 31 | put buf add start i get tmp sub sub n i 1 |
| 32 | end |
| 33 | ret add start n |
| 34 | end |