| Simulink® | ![]() |
Determine exponent that gives best precision fixed-point representation of value
out = fixptbestexp(RealWorldValue,TotalBits,IsSigned) out = fixptbestexp(RealWorldValue,FixPtDataType)
out = fixptbestexp(RealWorldValue,TotalBits,IsSigned) determines the exponent that gives the best precision for the fixed-point representation of the real-world value specified by RealWorldValue. You specify the number of bits for the fixed-point number with TotalBits, and you specify whether the fixed-point number is signed with IsSigned. If IsSigned is 1, the number is signed. If IsSigned is 0, the number is not signed. The exponent is returned to out.
out = fixptbestexp(RealWorldValue,FixPtDataType) determines the exponent that gives the best precision based on the data type specified by FixPtDataType.
The following command returns 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, you can specify the fixed-point data type:
out = fixptbestexp(4/3,sfix(16)) out = -14
This value means that the maximum precision representation of 4/3 is obtained by placing 14 bits to the right of the binary point:
01.01010101010101
You would specify the precision of this representation in fixed-point blocks by setting the scaling to 2^-14 or 2^fixptbestexp(4/3,16,1).
![]() | fixpt_set_all | fixptbestprec | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |