summaryrefslogtreecommitdiff
path: root/tests/src/bitwise.rs
blob: 9f48cb0455c48d20aeac4bf6d499d40b5bc62d2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//! Exercise the bitwise operations

pub fn shift_u32(a: u32) -> u32 {
    let i: usize = 16;
    let mut t = a >> i;
    t <<= i;
    t
}

pub fn shift_i32(a: i32) -> i32 {
    let i: isize = 16;
    let mut t = a >> i;
    t <<= i;
    t
}

pub fn xor_u32(a: u32, b: u32) -> u32 {
    a ^ b
}

pub fn or_u32(a: u32, b: u32) -> u32 {
    a | b
}

pub fn and_u32(a: u32, b: u32) -> u32 {
    a & b
}