3.0 KiB
3.0 KiB
id | title | description | hide_table_of_contents |
---|---|---|---|
bitwise-reference | Bitwise | Operations on bytes | true |
import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle';
function and : 'a -> nat -> nat val and : 'a -> nat -> nat let and: ('a, nat) => nat'a
can either be an int
or nat
.
A bitwise and
operation.
const zero: nat = Bitwise.and(2n, 1n)
let zero: nat = Bitwise.and 2n 1n
let zero: nat = Bitwise.and(2n, 1n);
function or : nat -> nat -> nat
val or : nat -> nat -> nat
let or: (nat, nat) => nat
A bitwise or
operation.
const three: nat = Bitwise.or(2n, 1n)
let three: nat = Bitwise.or 2n 1n
let three: nat = Bitwise.or(2n, 1n);
function xor : nat -> nat -> nat
val xor : nat -> nat -> nat
let xor: (nat, nat) => nat
A bitwise xor
operation.
const two: nat = Bitwise.xor(2n, 1n)
let two: nat = Bitwise.xor 2n 1n
let two: nat = Bitwise.xor(2n, 1n);
function shift_left : nat -> nat -> nat
val shift_left : nat -> nat -> nat
let shift_left: (nat, nat) => nat
A bitwise shift left operation.
const four: nat = Bitwise.shift_left(2n, 1n)
let four: nat = Bitwise.shift_left 2n 1n
let four: nat = Bitwise.shift_left(2n, 1n);
function shift_right : nat -> nat -> nat
val shift_right : nat -> nat -> nat
let shift_right: (nat, nat) => nat
A bitwise shift right operation.
const one: nat = Bitwise.shift_right(2n, 1n)
let one: nat = Bitwise.shift_right 2n 1n
let one: nat = Bitwise.shift_right(2n, 1n);