Main Content

getmsb

Most significant bit

Description

c = getmsb(a) returns the value of the most-significant bit in a.

example

Examples

collapse all

Use getmsb to find the most-significant bit in the fi object a.

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

          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.

disp(bin(a))
100110

Input Arguments

collapse all

Input fi object, specified as a scalar, vector, matrix, or multidimensional array. getmsb only supports fi object with fixed-point data types.

Data Types: fi

Extended Capabilities

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

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

Version History

Introduced in R2007b