Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

bitsll

Bit shift left logical

Syntax

c = bitsll(a, k)

Description

example

c = bitsll(a, k) returns the result of a logical left shift by k bits on input a for fixed-point operations. bitsll shifts zeros into the positions of bits that it shifts left. The function does not check overflow or underflow. For floating-point operations, bitsll performs a multiply by 2k.

bitsll ignores fimath properties such as RoundingMode and OverflowAction.

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

Examples

collapse all

Shift a signed fi input left by 1 bit.

Create a fi object, and display its binary value.

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

Shift a left by 1 bit, and display its binary value.

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

Shift a left by 1 more bit.

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

Shift left a built-in int8 input using a fi shift value.

k = fi(2);
a = int8(16);
bitsll(a,k)
ans =

  int8

   64

Use bitsll to shift an int8 input left by 2 bits.

a = int8(4);
bitsll(a,2)
ans =

  int8

   16

Scale a floating-point double input by $2^{3}$.

a = double(16);
bitsll(a,3)
ans =

   128

Input Arguments

collapse all

Data that you want to shift, specified as a scalar, vector, matrix, or multidimensional array of fi objects or built-in numeric types.

Data Types: fi | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Complex Number Support: Yes

Number of bits to shift, specified as a non-negative integer-valued scalar fi object or built-in numeric type.

Data Types: fi | single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Extended Capabilities

Introduced in R2007b

Was this topic helpful?