bitsll - Bit shift left logical

Syntax

c = bitsll(a, k)

Description

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

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 bitsll function. 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

Shift a left by one bit:

disp(bin(bitsll(a,1)))

0100

Shift a left by one more bit:

disp(bin(bitsll(a,2)))

1000

Unlike the bitshift function, the output value does not saturate.

See Also

bitconcat, bitrol, bitror, bitshift, bitsliceget, bitsra, bitsrl

  


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