Skip to Main Content Skip to Search
Product Documentation

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 any numeric type, including double, single, integer, or fixed-point. 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 a nonnegative, integer-valued constant.

When a is a fi object, a and c have the same associated fimath and numerictype objects.

Examples

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

You can also use bitsll with floating-point inputs. The following example scales the double input by 23:

y = double(128);
bitsll(y,3)

ans =

        1024

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-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS