Main Content

## fimath for Sharing Arithmetic Rules

There are two ways of sharing `fimath` properties in Fixed-Point Designer™ 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.

### Default fimath Usage to Share Arithmetic Rules

You can ensure that your `fi` objects are all using the same `fimath` properties by not specifying any local fimath. To assure no local `fimath` is associated with a `fi` object, you can:

• Create a `fi` object using the `fi` constructor without specifying 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 have no local fimath.

`b = sfi(pi)`
• Use `removefimath` to remove a local `fimath` object from an existing `fi` object.

### Local fimath Usage to Share Arithmetic Rules

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 numerictype Object Construction 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('RoundingMethod','Floor',... 'OverflowAction','Wrap')```
```F = RoundingMethod: Floor OverflowAction: Wrap ProductMode: FullPrecision SumMode: FullPrecision ```
`a = fi(pi, T, F)`
```a = -0.8584 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 32 FractionLength: 30 RoundingMethod: Floor OverflowAction: Wrap ProductMode: FullPrecision SumMode: FullPrecision ```
`b = fi(pi/2, T, F)`
```b = 1.5708 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 32 FractionLength: 30 RoundingMethod: Floor OverflowAction: Wrap ProductMode: FullPrecision SumMode: FullPrecision ```

## Support Get trial now