# [Matlab] >>(right shift) and <<(left shift)

Status
Not open for further replies.

#### davyzhu matlab shift

Hi all,

How >>(right shift) and <<(left shift) 2'complement number
(both positive and negative integer).

Is x>>2 equal to floor(x/4)?

And is x<<2 equal to x*4?

Best regards,
Davy

#### hr_rezaee shift matlab

hi
see bitshift in help of matlab
regards

• mselman

### mselman

Points: 2

#### davyzhu matlab left shift

Hi hr_rezaee,

Thanks!

The bitshift C = bitshift(A, k) returns the value of A shifted by k bits. Input argument A must be an unsigned integer or an array of unsigned integers.

But I need the signed version.

I used to use floor(x/(2^n)) to emulate x>>n, is it right?

Best regards,
Davy

#### davyzhu matlab shift left

Hi,

I copy the x >> y definition from a video standard (H.264).

Arithmetic right shift of a two's complement integer representation of x by y binary digits. This function is defined only for positive integer values of y. Bits shifted into the MSBs as a result of the right shift have a value equal to the MSB of x prior to the shift
operation.

Did matlab provide a arithmetic shift function?

Best regards,
Davy

• hr_rezaee

### hr_rezaee

Points: 2

#### hr_rezaee matlab bit shift

Hi
I don't know but study "Simulink Reference>Shift Arithmetic" and "Simulink Fixed Point>shifts".
regards

#### farhantariq

##### Member level 3 matlab shift function

why dont u check MATLAB help for exact answer.u will find brief explanation there

Status
Not open for further replies.