bitshift
Shift the bits of an integer left or right.
Syntax
Section titled “Syntax”B = bitshift(A, k)B = bitshift(A, k, type)Description
Section titled “Description”Shifts each element of A by k bits — left if k is positive, right if k is negative. Right shifts on signed types replicate the sign bit (arithmetic shift); right shifts on unsigned types fill with zeros (logical shift).
The optional type string controls how A is interpreted (defaults to int64). Bits shifted past the integer’s width are discarded.
Examples
Section titled “Examples”bitshift(1, 4) % 16 (1 << 4)bitshift(1024, -3) % 128 (1024 >> 3)bitshift(uint8(255), 1) % 254 (overflow drops high bit)