interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / tests / native / freestanding / f32.om

50 lines · 818 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2om2
3fn mean32 a f32 b f32 to f32
4two = f32 2.0e+0f32
5ret div add a b two
6end
7export fn f32bits mode ulong abits ulong bbits ulong cbits ulong to ulong
8a = bitcast f32 uint abits
9b = bitcast f32 uint bbits
10c = bitcast f32 uint cbits
11if eq mode 0
12ret ulong bitcast uint a
13end
14if eq mode 1
15ret ulong bitcast uint add a b
16end
17if eq mode 2
18ret ulong bitcast uint div a b
19end
20if eq mode 3
21ret ulong bitcast uint neg a
22end
23if eq mode 4
24ret ulong bitcast uint mean32 a b
25end
26if eq mode 5
27p = mul a b
28ret ulong bitcast uint add p c
29end
30flags = ulong 0
31if eq a b
32flags = or flags 1
33end
34if ne a b
35flags = or flags 2
36end
37if lt a b
38flags = or flags 4
39end
40if le a b
41flags = or flags 8
42end
43if gt a b
44flags = or flags 16
45end
46if ge a b
47flags = or flags 32
48end
49ret flags
50end