Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/drafts/rosettacode/number-names.wiki # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / drafts / rosettacode / number-names.wiki` 147 lines ยท 2914 bytes Raw Blame History 1 =={{header|Omegese}}== 2 {{works with|omc|sha256 `2c824805`, aien-dev/omega-mv `e5b32567`, Linux AArch64}} 3 Omega has no imports, so the small output helpers (emit and friends) are part of the program. 4 5 om2 6 text nl "\n" 7 text sp " " 8 text hy "-" 9 text colon ": " 10 text ones "zero\none\ntwo\nthree\nfour\nfive\nsix\nseven\neight\nnine\nten\neleven\ntwelve\nthirteen\nfourteen\nfifteen\nsixteen\nseventeen\neighteen\nnineteen\n" 11 text tens "twenty\nthirty\nforty\nfifty\nsixty\nseventy\neighty\nninety\n" 12 text scales "thousand\nmillion\nbillion\ntrillion\nquadrillion\nquintillion\n" 13 text hund " hundred" 14 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 15 fn emit a view uchar * to void 16 o = ulong 0 17 while lt o len a bound 4096 18 k = write 1 a o sub len a o 19 if le k 0 20 exit 1 21 end 22 o = add o ulong k 23 end 24 end 25 note emitu writes n in decimal; 20 digits hold every ulong 26 fn emitu n ulong to void 27 d = new uchar 20 0 28 i = ulong 20 29 v = n 30 while true bound 20 31 i = sub i 1 32 put d i uchar add rem v 10 48 33 v = div v 10 34 if eq v 0 35 break 36 end 37 end 38 emit part d i sub 20 i 39 end 40 note word writes element k of a newline-terminated list 41 fn word t view uchar * k ulong to void 42 s = ulong 0 43 m = ulong 0 44 for i ulong len t 45 if eq get t i 10 46 if eq m k 47 emit part t s sub i s 48 ret 49 end 50 m = add m 1 51 s = add i 1 52 end 53 end 54 trap 9 55 end 56 note three writes 1..999 in words: hundreds, then the rest (under 20 by name, else tens-ones) 57 fn three g ulong to void 58 h = div g 100 59 r = rem g 100 60 if gt h 0 61 word ones h 62 emit hund 63 if gt r 0 64 emit sp 65 end 66 end 67 if and gt r 0 lt r 20 68 word ones r 69 end 70 if ge r 20 71 word tens sub div r 10 2 72 if gt rem r 10 0 73 emit hy 74 word ones rem r 10 75 end 76 end 77 end 78 note spell splits n into groups of three digits and writes each non-zero one with its scale 79 fn spell n ulong to void 80 if eq n 0 81 word ones 0 82 ret 83 end 84 g = new ulong 7 0 85 v = n 86 for i ulong 7 87 put g i rem v 1000 88 v = div v 1000 89 end 90 first = true 91 for k ulong 7 92 i = sub 6 k 93 x = get g i 94 if gt x 0 95 if not first 96 emit sp 97 end 98 three x 99 if gt i 0 100 emit sp 101 word scales sub i 1 102 end 103 first = false 104 end 105 end 106 end 107 fn show n ulong to void 108 emitu n 109 emit colon 110 spell n 111 emit nl 112 end 113 fn main to int 114 show 0 115 show 7 116 show 13 117 show 21 118 show 99 119 show 100 120 show 101 121 show 999 122 show 1000 123 show 1001 124 show 12345 125 show `1000000` 126 show `1234567890` 127 show `18446744073709551615` 128 ret 0 129 end 130 131 {{out}} 132

133 0: zero

134 7: seven

135 13: thirteen

136 21: twenty-one

137 99: ninety-nine

138 100: one hundred

139 101: one hundred one

140 999: nine hundred ninety-nine

141 1000: one thousand

142 1001: one thousand one

143 12345: twelve thousand three hundred forty-five

144 `1000000`: one million

145 `1234567890`: one billion two hundred thirty-four million five hundred sixty-seven thousand eight hundred ninety

146 `18446744073709551615`: eighteen quintillion four hundred forty-six quadrillion seven hundred forty-four trillion seventy-three billion seven hundred nine million five hundred fifty-one thousand six hundred fifteen

147