Documentation

bitrol

Bitwise rotate left

Syntax

c = bitrol(a, k)

Description

example

c = bitrol(a,k)returns the value of the fixed-pointfiobject,a, rotated left bykbits.bitrolrotates bits from the most significant bit (MSB) side into the least significant bit (LSB) side. It performs the rotate left operation on the stored integer bits ofa.

bitroldoes not check overflow or underflow. It ignoresfimathproperties such asRoundingModeandOverflowAction.

aandchave the samefimathandnumerictypeproperties.

Examples

collapse all

Create an unsigned fixed-pointfiobject with a value of 10, word length 4, and fraction length 0.

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

Rotatealeft 1 bit.

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

Rotatealeft 2 bits.

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

Create a vector offiobjects.

a = fi([1,2,5,7],0,4,0)
a = 1 2 5 7 DataTypeMode: Fixed-point: binary point scaling Signedness: Unsigned WordLength: 4 FractionLength: 0
disp(bin(a))
0001 0010 0101 0111

Rotate the bits in vectoraleft 1 bit.

disp(bin(bitrol(a,1)))
0010 0100 1010 1110

Create an unsigned fixed-pointfiobject with a value 10, word length 4, and fraction length 0.

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

Rotatealeft 1 bit wherekis afiobject.

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

Input Arguments

collapse all

你想旋转的数据, specified as a scalar, vector, matrix, or multidimensional array offiobjects.acan be signed or unsigned.

Data Types: fixed-pointfi

Complex Number Support: Yes

Number of bits to rotate, specified as a non-negative integer-valued scalarfiobject or built-in numeric type.kcan be greater than the word length ofa. This value is always normalized tomod(a.WordLength,k).

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

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2007b

Was this topic helpful?