www.gusucode.com > fixedpoint 案例源码程序 matlab代码 > fixedpoint/ShiftRightaSignedfiInputExample.m

    %% Shift Right a Signed fi Input  

% Copyright 2015 The MathWorks, Inc.


%% 
% Create a signed fixed-point |fi| object with a value of –8, word length
% 4, and fraction length 0. Then display the binary value of the object. 
a = fi(-8,1,4,0);
disp(bin(a))  

%% 
% Shift |a| right by 1 bit. 
disp(bin(bitsra(a,1))) 

%%
% |bitsra| shifts the MSB into the position of the bit that it shifts right.