Capy-Bearer Documentation

bit_shr

lib call

Capy

function bit_shr(value : s8, count : s8) s8
function bit_shr(value : s16, count : s16) s16
function bit_shr(value : s32, count : s32) s32
function bit_shr(value : s64, count : s64) s64
function bit_shr(value : u8, count : u8) u8
function bit_shr(value : u16, count : u16) u16
function bit_shr(value : u32, count : u32) u32
function bit_shr(value : u64, count : u64) u64

Description

A signed value shifts arithmetically and keeps its sign: bit_shr(-16, 2) is -4. An unsigned value shifts in zeros. A right shift by n divides by 2^n, rounding toward negative infinity for signed values. The count is taken modulo the type width.

Parameters

value : an integer

count : how many positions to shift, in the same type

Return Values

value moved count bits toward the low end, in the same type.

Example

Capy

print(bit_shr(1024, 10), " ", bit_shr(-16, 2), " ", bit_shr(u8(255), u8(4)), "\n")

Output

1 -4 15