starcoin-framework

Module 0x1::BitOperators

Functions for bit operations.

Function and

bit and: x & y

public fun and(x: u64, y: u64): u64
Implementation
public fun and(x: u64, y: u64): u64 {
    (x & y as u64)
}

Function or

bit or: x y
public fun or(x: u64, y: u64): u64
Implementation
public fun or(x: u64, y: u64): u64 {
    (x | y as u64)
}

Function xor

bit xor: x ^ y

public fun xor(x: u64, y: u64): u64
Implementation
public fun xor(x: u64, y: u64): u64 {
    (x ^ y as u64)
}

Function not

bit not: !x

public fun not(x: u64): u64
Implementation
public fun not(x: u64): u64 {
   (x ^ 18446744073709551615u64 as u64)
}

Function lshift

left shift n bits.

public fun lshift(x: u64, n: u8): u64
Implementation
public fun lshift(x: u64, n: u8): u64 {
    (x << n  as u64)
}

Function rshift

right shift n bits.

public fun rshift(x: u64, n: u8): u64
Implementation
public fun rshift(x: u64, n: u8): u64 {
    (x >> n  as u64)
}

Module Specification

pragma verify = false;