bitsrl

Bit shift right logical

Syntax

Description

example

c = bitsrl(a, k) returns the result of a logical right shift by k bits on input a for fixed-point operations. bitsrl shifts zeros into the positions of bits that it shifts right. It does not check overflow or underflow.

bitsrl 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

expand all

Shift Right a Signed fi Input

Shift a signed fi input right by 1 bit.

Create a signed fixed-point fi object 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

Shift a right by 1 bit, and display the binary value.

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

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

Shift right using a fi shift value

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

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

   16

Shift right a built-in uint8 input

Use bitsrl to shift an uint8 input right by 2 bits.

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

Input Arguments

expand all

a — Data that you want to shiftscalar | vector | matrix | multidimensional array

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

k — Number of bits to shiftnon-negative integer-valued scalar

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

Was this topic helpful?