Fixed-Point Blockset | ![]() ![]() |
Determine the maximum precision available for the fixed-point representation of a value
Syntax
out = fixptbestprec(RealWorldValue,TotalBits,IsSigned) out = fixptbestprec(RealWorldValue,FixPtDataType)
Description
out = fixptbestprec(RealWorldValue,TotalBits,IsSigned)
determines the maximum 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 maximum precision is returned to out
.
out = fixptbestprec(RealWorldValue,FixPtDataType)
determines the maximum precision based on the data type specified by FixPtDataType
.
Example
The following command returns the maximum precision available for the real-world value 4/3 using a signed, 8-bit number:
Alternatively, you can specify the fixed-point data type:
This value means that the maximum precision available for 4/3 is obtained by placing six bits to the right of the radix point since 2-6 equals 0.015625:
You can use the maximum precision as the scaling parameter in fixed-point blocks.
See Also
![]() | fixptbestexp | fixpt_convert | ![]() |