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/shifts.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 / shifts.osc` 15 lines ยท 667 bytes Raw Blame History 1 // entry: shl_i32 shr_i8 mix_u64 rot_u32 2 // expect-run: shl_i32 1 30 -> `1073741824` 3 // expect-run: shl_i32 1 31 -> trap=OVERFLOW 4 // expect-run: shl_i32 1 32 -> trap=SHIFT 5 // expect-run: shr_i8 `18446744073709551488` 7 -> `18446744073709551615` 6 // shifts with amounts of any integer type; amount >= width traps SHIFT, 7 // signed << that loses bits traps OVERFLOW. 8 fn shl_i32(x: i32, n: u8) -> i32 { return x << n; } 9 fn shr_i8(x: i8, n: i64) -> i8 { return x >> n; } 10 fn mix_u64(x: u64, n: i16) -> u64 { return (x << n) ^ (x >> 3) ^ (1 << 63); } 11 fn rot_u32(x: u32, n: u32) -> u32 { 12 let k: u32 = n % 32; 13 if k == 0 { return x; } 14 return (x << k) | (x >> (32 - k)); 15 }