FUNCTION REFERENCE

bitshift

Shift bits.

Shift bits.

Syntax

c = bitshift(a, k)

Syntax

c = bitshift(a, k, assumedtype)

Shifts integer a left by k bits, right if k is negative. assumedtype defaults

to 'uint64'; accepted names are 'uint8', 'uint16', 'uint32', 'uint64', 'int8',

'int16', 'int32', and 'int64'. Bits beyond the type width are dropped; signed

right shifts preserve the sign. Inputs must fit the assumed type and have

absolute value at most 2^53. Results are rounded to double.

Example

bitshift(1, 4)   % 16

Integer arrays use their stored class and retain exact 64-bit values; scalar expansion is supported.

Differences from MATLAB: Typed integer inputs use the two-input form; assumed-type options apply to double inputs.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.