Handling Overflows and Underflows (Digital Filter Design Toolkit)
Fixed-point numbers can represent only numbers of a finite range. Overflows occur when a number is greater than the maximum representable number within the range. Underflows occur when a number is less than the minimum representable number within the range. You can handle overflows and underflows using one of the following two modes:
- Saturation—A quantizer converts the specified number to the maximum representable number in the case of an overflow or to the minimum representable number in the case of an underflow.
- Wrap—A quantizer wraps the specified value from the maximum representable number to the minimum representable number in the case of an overflow and from the minimum representable number to the maximum representable number in the case of an underflow. In the wrap mode, when an overflow or an underflow occurs, the absolute value of the error is 2iwl, which is greater than the total available dynamic range.
The saturation mode of the output quantizer is preferred over the wrap mode in most real-world applications because the saturation mode helps avoid signal discontinuities, or sudden changes in the amplitudes. However, the saturation mode is more complicated than the wrap mode. For internal quantizers, such as the sum quantizer, the wrap mode is preferred because this mode allows intermediate overflows and underflows within a certain range as long as the final output does not contain overflows or underflows. Use the overflow mode input of the Fixed-Point Tools VIs to specify an appropriate setting for handling overflows and underflows.