bitsra - Bit shift right arithmetic

Syntax

c = bitsra(a, k)

Description

c = bitsra(a, k) returns the value of the fi object a shifted right arithmetic by k bits.

a can be a scalar fi object or a vector fi object. It can be any fixed-point numeric type. The OverflowMode and RoundMode properties are ignored. bitsra operates on both signed and unsigned fixed point inputs and does not check overflow or underflow. bitsra shifts zeros into the positions of bits that it shifts right if the input is unsigned. bitsra shifts the MSB into the positions of bits that it shifts right if the input is signed.

k is an integer constant in the following range:

a.WordLength > k >= 0

a and c have the same fimath and the numerictype objects.

Example

This example shows how to shift bits using the bitsra function. Consider the following signed fixed-point fi object with a value of -8, word length 4, and fraction length 0:

a = fi(-8,1,4,0);
disp(bin(a))

1000

Shift a right by one bit:

disp(bin(bitsra(a,1)))

1100

bitsra shifts the MSB into the position of the bit that it shifts right.

See Also

bitconcat, bitshift, bitsliceget, bitsll, bitsrl

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS