| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Fixed-Point Toolbox |
| Contents | Index |
| Learn more about Fixed-Point Toolbox |
c = bitsra(a, k)
c = bitsra(a, k) performs an arithmetic right shift by k bits on input operand a.
a can be any numeric type, including double, single, integer, or fixed-point. For fixed-point operations, the OverflowMode and RoundMode properties are ignored. bitsra operates on both signed and unsigned inputs and does not check overflow or underflow. bitsra shifts zeros into the positions of bits that it shifts right if the input is unsigned. bitsra shifts the MSB into the positions of bits that it shifts right if the input is signed.
k is an integer constant in the following range:
a.WordLength > k >= 0
a and c have the same associated fimath and numerictype objects.
This example shows how to shift bits using the bitsra function. Consider the following signed fixed-point fi object with a value of -8, word length 4, and fraction length 0:
a = fi(-8,1,4,0); disp(bin(a)) 1000
Shift a right by one bit:
disp(bin(bitsra(a,1))) 1100
bitsra shifts the MSB into the position of the bit that it shifts right.
The bitsra function also supports built-in integer inputs. For example, you can use bitsra to shift the int8 input right by two bits:
x = int8(64); bitsra(x,2) ans = 16
You can also use bitsra with floating-point inputs. The following example shifts the double input right by three bits:
y = double(128);
bitsra(y,3)
ans =
16bitconcat, bitshift, bitsliceget, bitsll, bitsrl, pow2
![]() | bitsll | bitsrl | ![]() |

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