Capy-Bearer Documentation

bit_and

lib call

Capy

function bit_and(a : s8, b : s8) s8
function bit_and(a : s16, b : s16) s16
function bit_and(a : s32, b : s32) s32
function bit_and(a : s64, b : s64) s64
function bit_and(a : u8, b : u8) u8
function bit_and(a : u16, b : u16) u16
function bit_and(a : u32, b : u32) u32
function bit_and(a : u64, b : u64) u64

Description

Capy has no & operator; bit_and() is the bitwise AND. Masking keeps selected bits: bit_and(flags, u8(4)) is non-zero when bit 2 is set.

Parameters

a : the first integer

b : the second integer, in the same type

Return Values

An integer with a bit set where both inputs have it, in their type.

Example

Capy

var flags := u8(6)
print(bit_and(flags, u8(4)) != 0, " ", bit_and(flags, u8(1)) != 0, " ", bit_and(12, 10), "\n")

Output

true false 8