This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Exponent that gives best precision for fixed-point representation of value


out = fixptbestexp(RealWorldValue, TotalBits, IsSigned)
out = fixptbestexp(RealWorldValue, FixPtDataType)


out = fixptbestexp(RealWorldValue, TotalBits, IsSigned) returns the exponent that gives the best precision for the fixed-point representation of RealWorldValue. TotalBits specifies the number of bits for the fixed-point number. IsSigned specifies whether the fixed-point number is signed: 1 indicates the number is signed and 0 indicates the number is not signed.

out = fixptbestexp(RealWorldValue, FixPtDataType) returns the exponent that gives the best precision based on the data type FixPtDataType.


Get the exponent that gives the best precision for the real-world value 4/3 using a signed, 16-bit number:

out = fixptbestexp(4/3,16,1)
out =

Alternatively, specify the fixed-point data type:

out = fixptbestexp(4/3,sfix(16))
out =

This shows that the maximum precision representation of 4/3 is obtained by placing 14 bits to the right of the binary point:


You can specify the precision of this representation in fixed-point blocks by setting the scaling to 2^-14 or 2^fixptbestexp(4/3,16,1).

Introduced before R2006a