--- id: bitwise-reference title: Bitwise description: Operations on bytes hide_table_of_contents: 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. ```pascaligo const zero: nat = Bitwise.and(2n, 1n) ``` ```cameligo let zero: nat = Bitwise.and 2n 1n ``` ```reasonligo 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. ```pascaligo const three: nat = Bitwise.or(2n, 1n) ``` ```cameligo let three: nat = Bitwise.or 2n 1n ``` ```reasonligo 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. ```pascaligo const three: nat = Bitwise.xor(2n, 1n) ``` ```cameligo let three: nat = Bitwise.xor 2n 1n ``` ```reasonligo let three: 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. ```pascaligo const four: nat = Bitwise.shift_left(2n, 1n) ``` ```cameligo let four: nat = Bitwise.shift_left 2n 1n ``` ```reasonligo 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. ```pascaligo const one: nat = Bitwise.shift_right(2n, 1n) ``` ```cameligo let one: nat = Bitwise.shift_right 2n 1n ``` ```reasonligo let one: nat = Bitwise.shift_right(2n, 1n); ```