Products & Services Solutions Academia Support User Community Company

Learn more about Fixed-Point Toolbox   

bitsll - Bit shift left logical

Syntax

c = bitsll(a, k)

Description

c = bitsll(a, k) returns the value of the input operand a shifted left logical by k bits.

The input operand a can be a built-in integer or a fi object with a fixed-point data type. For fixed-point operations, the OverflowMode and RoundMode properties are ignored. bitsll operates on both signed and unsigned 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 associated fimath and 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.

The bitsll function also supports built-in integer inputs. The following example shows the uint8 input being shifted left by four bits:

x = uint8(50);
bitsll(x,4)

ans =
   32

See Also

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

  


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