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-mv/blob/main/tests/compiler/progs/ops.osc # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / tests / compiler / progs / ops.osc` 46 lines ยท 1158 bytes Raw Blame History 1 // entry: arith_i32 bits_u16 cmp_i16 cmp_u64 unary_i64 logic 2 // expect-run: arith_i32 7 0 -> trap=DIV0 3 // expect-run: cmp_i16 3 3 -> 41 4 // expect-run: logic 1 0 -> 1 5 // every operator: + - * / % & | ^ << >> == != < <= > >= && || ! - ~ as 6 fn arith_i32(a: i32, b: i32) -> i32 { 7 let s: i32 = a + b; 8 let d: i32 = a - b; 9 let p: i32 = (a % 1000) * (b % 1000); 10 let q: i32 = a / b; 11 let r: i32 = a % b; 12 return s / 2 + d / 2 + p + q + r; 13 } 14 15 fn bits_u16(a: u16, b: u16, n: u8) -> u16 { 16 return ((a & b) | (a ^ ~b)) + (a << n) + (b >> n); 17 } 18 19 fn cmp_i16(a: i16, b: i16) -> u8 { 20 let mut m: u8 = 0; 21 if a == b { m = m | 1; } 22 if a != b { m = m | 2; } 23 if a < b { m = m | 4; } 24 if a <= b { m = m | 8; } 25 if a > b { m = m | 16; } 26 if a >= b { m = m | 32; } 27 return m; 28 } 29 30 fn cmp_u64(a: u64, b: u64) -> u8 { 31 let mut m: u8 = 0; 32 if a < b { m = m + 1; } 33 if a <= b { m = m + 2; } 34 if a > b { m = m + 4; } 35 if a >= b { m = m + 8; } 36 if 100 < a { m = m + 16; } 37 return m; 38 } 39 40 fn unary_i64(a: i64) -> i64 { 41 return -a + ~a * 2; 42 } 43 44 fn logic(a: bool, b: bool) -> bool { 45 return !(a && b) == (!a || !b); 46 }