Skip to content

bitshift

general · scripts/general/bitshift.m

: C = bitshift (A, k)
: C = bitshift (A, k, assumedtype)

Shift the bits of integers in A by k places.

A positive k shifts toward the most significant bit; a negative k shifts the other way. Signed integer classes use two’s-complement arithmetic (including arithmetic right shifts). A and k must have the same size, or either may be scalar.

A must be an integer class or double. Doubles are treated as "uint64" unless assumedtype names another integer class; the result for a double input is always double. Integer inputs may only be paired with an assumedtype that matches class (A).