fimath

Set fixed-point math settings

Syntax

F = fimath
F = fimath(...'PropertyName',PropertyValue...)

Description

You can use the fimath constructor function in the following ways:

  • F = fimath creates a fimath object with default fimath property settings:

            RoundingMethod: Nearest
            OverflowAction: Saturate
               ProductMode: FullPrecision
                   SumMode: FullPrecision
    
  • F = fimath(...'PropertyName',PropertyValue...) allows you to set the attributes of a fimath object using property name/property value pairs. All property names that you do not specify in the constructor use default values.

The properties of the fimath object are listed below. These properties are described in detail in fimath Object Properties in the Properties Reference.

  • CastBeforeSum — Whether both operands are cast to the sum data type before addition

      Note:   This property is hidden when the SumMode is set to FullPrecision.

  • OverflowAction — Action to take on overflow

  • ProductBias — Bias of the product data type

  • ProductFixedExponent — Fixed exponent of the product data type

  • ProductFractionLength — Fraction length, in bits, of the product data type

  • ProductMode — Defines how the product data type is determined

  • ProductSlope — Slope of the product data type

  • ProductSlopeAdjustmentFactor — Slope adjustment factor of the product data type

  • ProductWordLength — Word length, in bits, of the product data type

  • RoundingMethod — Rounding method

  • SumBias — Bias of the sum data type

  • SumFixedExponent — Fixed exponent of the sum data type

  • SumFractionLength — Fraction length, in bits, of the sum data type

  • SumMode — Defines how the sum data type is determined

  • SumSlope — Slope of the sum data type

  • SumSlopeAdjustmentFactor — Slope adjustment factor of the sum data type

  • SumWordLength — Word length, in bits, of the sum data type

Examples

expand all

Create a Default fimath Object

F = fimath
 
F =
 

        RoundingMethod: Nearest
        OverflowAction: Saturate
           ProductMode: FullPrecision
               SumMode: FullPrecision

Set Properties of a fimath Object

Set properties of a fimath object at the time of object creation by including properties after the arguments of the fimath constructor function. For example, set the overflow action to Saturate and the rounding method to Convergent.

F = fimath('OverflowAction','Saturate','RoundingMethod','Convergent')
 
F =
 

        RoundingMethod: Convergent
        OverflowAction: Saturate
           ProductMode: FullPrecision
               SumMode: FullPrecision
Was this topic helpful?