Main Content


Most significant bit


c = getmsb(a)


c = getmsb(a) returns the value of the most significant bit in a as a u1,0.

a can be a scalar fi object or a vector fi object.

getmsb only supports fi objects with fixed-point data types.


The following example uses getmsb to find the most significant bit in the fi object a.

a = fi(-26, 1, 6, 0);
c = getmsb(a)

c =

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Unsigned
            WordLength: 1
        FractionLength: 0

You can verify that the most significant bit in the fi object a is 1 by looking at the binary representation of a.



Extended Capabilities

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

HDL Code Generation
Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.

Introduced in R2007b