Products & Services Solutions Academia Support User Community Company

Learn more about Fixed-Point Toolbox   

bitrol - Bitwise rotate left

Syntax

c = bitrol(a, k)

Description

c = bitrol(a, k) returns the value of the fi object a rotated left 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. bitrol operates on both signed and unsigned fixed point inputs and does not check overflow or underflow. bitrol rotates bits from the MSB side into the LSB side.

k is an integer constant that must be greater than zero. k can be greater than the word length of a. It is always normalized to mod(a.WordLength,k).

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

Example

This example shows how to rotate the bits of a fi object left. Consider the following unsigned fixed-point fi object with a value of 10, word length 4, and fraction length 0:

a = fi(10,0,4,0);
disp(bin(a))

1010

Rotate a left one bit:

disp(bin(bitrol(a,1)))

0101

Rotate a left two bits:

disp(bin(bitrol(a,2)))

1010

See Also

bitconcat, bitror, bitshift, bitsliceget, bitsll, bitsra, bitsrl

  


Free Early Verification Kit

Learn how to apply early verification to your development process through these technical resources.

How much time do you spend on testing to ensure implementation meets system-level requirements?

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