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/temperature-conversion.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 / temperature-conversion.wiki`
108 lines ยท 1698 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 tk "K "
8 text tc "C "
9 text tf "F "
10 text tr "R "
11 text minus "-"
12 text dot "."
13 note emit writes every byte of a to stdout; a short write is retried, an error exits 1
14 fn emit a view uchar * to void
15 o = ulong 0
16 while lt o len a bound 4096
17 k = write 1 a o sub len a o
18 if le k 0
19 exit 1
20 end
21 o = add o ulong k
22 end
23 end
24 note emitu writes n in decimal; 20 digits hold every ulong
25 fn emitu n ulong to void
26 d = new uchar 20 0
27 i = ulong 20
28 v = n
29 while true bound 20
30 i = sub i 1
31 put d i uchar add rem v 10 48
32 v = div v 10
33 if eq v 0
34 break
35 end
36 end
37 emit part d i sub 20 i
38 end
39 note emitc2 writes v hundredths (signed) as a decimal with two places
40 fn emitc2 v long to void
41 u = ulong 0
42 if lt v 0
43 emit minus
44 u = ulong neg v
45 else
46 u = ulong v
47 end
48 emitu div u 100
49 emit dot
50 f = rem u 100
51 if lt f 10
52 emitu 0
53 end
54 emitu f
55 end
56 note k is kelvin in hundredths, a multiple of 5 so every scale below is exact in hundredths:
57 note C = K - 273.15, F = K * 9/5 - 459.67, R = K * 9/5
58 fn show k long to void
59 emit tk
60 emitc2 k
61 emit nl
62 emit tc
63 emitc2 sub k 27315
64 emit nl
65 emit tf
66 emitc2 sub div mul k 9 5 45967
67 emit nl
68 emit tr
69 emitc2 div mul k 9 5
70 emit nl
71 emit nl
72 end
73 fn main to int
74 show 2100
75 show 0
76 show 27315
77 show 37315
78 show 31015
79 ret 0
80 end
81
82 {{out}}
83
84 K 21.00
85 C -252.15
86 F -421.87
87 R 37.80
88
89 K 0.00
90 C -273.15
91 F -459.67
92 R 0.00
93
94 K 273.15
95 C 0.00
96 F 32.00
97 R 491.67
98
99 K 373.15
100 C 100.00
101 F 212.00
102 R 671.67
103
104 K 310.15
105 C 37.00
106 F 98.60
107 R 558.27
108