| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Fixed-Point Toolbox |
| Contents | Index |
| Learn more about Fixed-Point Toolbox |
There are two ways of sharing fimath properties in Fixed-Point Toolbox software:
Sharing fimath properties across fi objects ensures that the fi objects are using the same arithmetic rules and helps you avoid "mismatched fimath" errors.
You can ensure that your fi objects are all using the same fimath properties by associating them with the global fimath. To associate a fi object with the global fimath, you can:
Create a fi object using the fi constructor, and do not specify any fimath properties in the constructor call. For example:
a = fi(pi)
Create a fi object using the sfi or ufi constructor. All fi objects created with these constructors associate themselves with the global fimath.
b = sfi(pi)
Use dot notation to remove an attached fimath object from an existing fi object. Doing so automatically associates the fi object with the global fimath. For example:
b = fi(pi, 'RoundMode', 'Fix') b.fimath = []
To learn how to configure the global fimath, see Working with the Global fimath.
You can also use a fimath object to define common arithmetic rules that you would like to use for multiple fi objects. You can then create your fi objects, using the same fimath object for each. To do so, you must also create a numerictype object to define a common data type and scaling. Refer to Working with numerictype Objects for more information on numerictype objects. The following example shows the creation of a numerictype object and fimath object, and then uses those objects to create two fi objects with the same numerictype and fimath attributes:
T = numerictype('WordLength', 32, 'FractionLength', 30)
T =
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 30
F = fimath('RoundMode', 'floor', 'OverflowMode', 'wrap')
F =
RoundMode: floor
OverflowMode: wrap
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: true
a = fi(pi, T, F)
a =
-0.8584
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 30
RoundMode: floor
OverflowMode: wrap
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: true
b = fi(pi/2, T, F)
b =
1.5708
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 32
FractionLength: 30
RoundMode: floor
OverflowMode: wrap
ProductMode: FullPrecision
MaxProductWordLength: 128
SumMode: FullPrecision
MaxSumWordLength: 128
CastBeforeSum: true
![]() | Using fimath to Specify Rounding and Overflow Modes | Using fimath ProductMode and SumMode | ![]() |

Learn how to apply early verification to your development process through these technical resources.
How much time do you spend on testing to ensure implementation meets system-level requirements?
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |