Main Content

Negative Fraction Length

A negative fraction length occurs when the input value of a fi object contains trailing zeros before the decimal point. For example,

x = fi(16000,1,8)

produces a signed fixed-point number with a word length of 8 bits and best precision fraction length.

x = 

       16000

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 8
        FractionLength: -7

View the binary representation of x.

disp(bin(x))
01111101

There are seven implicit zeros at the end of this number before the binary point because the fraction length of x is -7.

Convert from binary to decimal the binary representation of x with seven zero bits appended to the end.

bin2dec('011111010000000')
ans =

       16000

The result is the real world value of x.

You can also find the real world value using the equation Real World Value = Stored Integer Value × 2Fraction Length.

Start by finding the stored integer of x.

Q = storedInteger(x)
Q =

  125

Use the stored integer to find the real world value of x.

real_world_value = double(Q) * 2^-x.FractionLength
real_world_value =

       16000

See Also