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,

V V ˜ = S Q + 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 encodesV.

  • S=F2Eis the slope.

  • Bis the bias.

For a cast operation,

S a Q a + B a = S b Q b + B b

or

Q a = S b Q b S a + ( B b B a S a ) ,

where:

  • S b S a is the net slope.

  • B b B a S a 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 theDiagnostics>Type Conversionpane. Set the parameters towarningorerrorso that Simulink alerts you when precision issues occur.

Configuration Parameter Specifies Default
Detect underflow Diagnostic action when a fixed-point constant underflow occurs during simulation Does not generate a warning or error.
Detect overflow Diagnostic action when a fixed-point constant overflow occurs during simulation Does not generate a warning or error.
Detect precision loss 当一个定点常数prec诊断行动ision loss occurs during simulation Does 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

定点常数下溢修复时发生ed-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 is200and the converted data type isint8. Overflow occurs in this case because the maximum value thatint8can represent is127.

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, seeFixed-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 thatint8can represent is127. The precision forint8is1.0. An ideal value of127.3quantizes to127with an absolute error of0.3. Although the ideal value127.3is greater than the maximum representable value forint8, the quantization error is small relative to the precision ofint8. Therefore the Fixed-Point Designer software does not report an overflow. However, an ideal value of128.1does cause an overflow because the quantization error is1.1, which is larger than the precision forint8.

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, seeDetect 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