bit_shl
lib callCapy
function bit_shl(value : s8, count : s8) s8 function bit_shl(value : s16, count : s16) s16 function bit_shl(value : s32, count : s32) s32 function bit_shl(value : s64, count : s64) s64 function bit_shl(value : u8, count : u8) u8 function bit_shl(value : u16, count : u16) u16 function bit_shl(value : u32, count : u32) u32 function bit_shl(value : u64, count : u64) u64
Description
A left shift by n multiplies by 2^n modulo the type width: bit_shl(u8(200), u8(1)) is 144, not 400. The count is taken modulo the width, as in WebAssembly, so a shift by the full width leaves the value unchanged.
Parameters
value : an integer
count : how many positions to shift, in the same type
Return Values
value moved count bits toward the high end, in the same type. Bits shifted out are lost; new low bits are zero.
Example
Capy
print(bit_shl(1, 10), " ", bit_shl(u8(200), u8(1)), "\n")
Output
1024 144