Documentation

fixptbestexp

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

Syntax

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

Description

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

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

Examples

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 = -14

Alternatively, specify the fixed-point data type:

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

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

01.01010101010101

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

See Also

Introduced before R2006a

Was this topic helpful?