Main Content

Net Slope and Net Bias Precision

What are Net Slope and Net Bias?

You can represent a fixed-point number by a general slope and bias encoding scheme,

VV˜=SQ+B,

where:

  • V is an arbitrarily precise real-world value.

  • V˜ is the approximate real-world value.

  • Q, the stored value, is an integer that encodes V.

  • S = F2E is the slope.

  • B is the bias.

For a cast operation,

SaQa+Ba=SbQb+Bb

or

Qa=SbQbSa+(BbBaSa),

where:

  • SbSa is the net slope.

  • BbBaSa is the net bias.

Detect Net Slope and Net Bias Precision Issues

Precision issues might occur in the fixed-point constants, net slope and net bias, due to quantization errors when you convert from floating point to fixed point. These fixed-point constant precision issues can result in numerical inaccuracy in your model.

You can configure your model to alert you when fixed-point constant precision issues occur.

You can configure your model to alert you when fixed-point constant precision issues occur. To receive alerts when fixed-point constant precision issues occur, use these options available in the Simulink® Configuration Parameters dialog box, on the Diagnostics > Type Conversion pane. Set the parameters to warning or error so that Simulink alerts you when precision issues occur.

Configuration ParameterSpecifiesDefault
Detect underflow Diagnostic action when a fixed-point constant underflow occurs during simulationDoes not generate a warning or error.
Detect overflowDiagnostic action when a fixed-point constant overflow occurs during simulationDoes not generate a warning or error.
Detect precision lossDiagnostic action when a fixed-point constant precision loss occurs during simulationDoes not generate a warning or error.

The Fixed-Point Designer™ software provides the following information:

  • The type of precision issue: underflow, overflow, or precision loss.

  • The original value of the fixed-point constant.

  • The quantized value of the fixed-point constant.

  • The error in the value of the fixed-point constant.

  • The block that introduced the error.

This information warns you that the outputs from this block are not accurate. If possible, change the data types in your model to fix the issue.

Fixed-Point Constant Underflow

Fixed-point constant underflow occurs when the Fixed-Point Designer software encounters a fixed-point constant whose data type does not have enough precision to represent the ideal value of the constant, because the ideal value is too close to zero. Casting the ideal value to the fixed-point data type causes the value of the fixed-point constant to become zero. Therefore the value of the fixed-point constant differs from its ideal value.

Fixed-Point Constant Overflow

Fixed-point constant overflow occurs when the Fixed-Point Designer software converts a fixed-point constant to a data type whose range is not large enough to accommodate the ideal value of the constant with reasonable precision. The data type cannot accurately represent the ideal value because the ideal value is either too large or too small. Casting the ideal value to the fixed-point data type causes overflow. For example, suppose the ideal value is 200 and the converted data type is int8. Overflow occurs in this case because the maximum value that int8 can represent is 127.

The Fixed-Point Designer software reports an overflow error if the quantized value differs from the ideal value by more than the precision for the data type. The precision for a data type is approximately equal to the default scaling (for more information, see Fixed-Point Data Type Parameters.) Therefore, for positive values, the Fixed-Point Designer software treats errors greater than the slope as overflows. For negative values, it treats errors greater than or equal to the slope as overflows.

For example, the maximum value that int8 can represent is 127. The precision for int8 is 1.0. An ideal value of 127.3 quantizes to 127 with an absolute error of 0.3. Although the ideal value 127.3 is greater than the maximum representable value for int8, the quantization error is small relative to the precision of int8. Therefore the Fixed-Point Designer software does not report an overflow. However, an ideal value of 128.1 does cause an overflow because the quantization error is 1.1, which is larger than the precision for int8.

Note

Fixed-point constant overflow differs from fixed-point constant precision loss. Precision loss occurs when the ideal fixed-point constant value is within the range of the current data type and scaling, but the software cannot represent this value exactly.

Fixed-Point Constant Precision Loss

Fixed-point constant precision loss occurs when the Fixed-Point Designer software converts a fixed-point constant to a data type without enough precision to represent the exact value of the constant. As a result, the quantized value differs from the ideal value. For an example of this behavior, see Detect Fixed-Point Constant Precision Loss.

Note

Fixed-point constant precision loss differs from fixed-point constant overflow. Overflow occurs when the range of the parameter data type, that is, the maximum value that it can represent, is smaller than the ideal value of the parameter.

Related Topics