bitsrl - Bit shift right logical

Syntax

c = bitsrl(a, k)

Description

c = bitsrl(a, k) returns the value of a shifted right logical 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. bitsrl operates on both signed and unsigned fixed point inputs and does not check overflow or underflow. bitsrl shifts zeros into the positions of bits that it shifts right.

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 bitsrl 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(bitsrl(a,1)))

0100

bitsrl shifts a zero into the position of the bit that it shifts right.

See Also

bitconcat, bitrol, bitror, bitshift, bitsliceget, bitsll, bitsra

  


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