Documentation

bitsrl

Bit shift right logical

Syntax

c = bitsrl(a, k)

Description

example

c = bitsrl(a,k)returns the result of a logical right shift bykbits on inputa为定点操作。bitsrlshifts zeros into the positions of bits that it shifts right. It does not check overflow or underflow.

bitsrlignoresfimathproperties such asRoundingModeandOverflowAction.

Whenais afiobject,aandchave the same associatedfimathandnumerictypeobjects.

Examples

collapse all

Shift a signedfiinput right by 1 bit.

Create a signed fixed-pointfiobject with a value of -8, word length 4, and fraction length 0 and display its binary value.

a = fi(-8,1,4,0); disp(bin(a))
1000

Shiftaright by 1 bit, and display the binary value.

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

bitsrlshifts a zero into the position of the bit that it shifts right.

Shift right a built-inint8input using afishift value.

k = fi(2); a = int8(64); bitsrl(a,k)
ans =int816

Usebitsrlto shift a uint8 input right by 2 bits.

a = uint8(64); bitsrl(a,2)
ans =uint816

Input Arguments

collapse all

Data that you want to shift, specified as a scalar, vector, matrix, or multidimensional array.

Data Types:fi|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.

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

Extended Capabilities

Introduced in R2007b

Was this topic helpful?