Choose a Rounding Mode
Fixed-Point Designer™ provides seven rounding modes you can choose from. Because rounding results in precision loss, quantization errors, and computational noise, you must carefully choose a rounding mode that gives fits the needs of your design. The two most important factors to consider when choosing a rounding mode are cost and bias.
Cost — How much processing expense the rounding method requires:
Low cost — The method requires few processing cycles.
Moderate cost— The method requires a moderate number of processing cycles.
High cost— The method requires more processing cycles.
Note
The cost estimates provided here are hardware independent. Some processors have rounding modes built-in, so it is important to consider the hardware you are using before calculating the true cost of each rounding mode.
Bias — The expected value of the rounded values minus the original values: .
— The rounding method introduces a negative bias.
— The rounding method is unbiased.
— The rounding method introduces a positive bias.
Fixed-Point Designer Rounding Modes
To provide you with flexibility in the tradeoff between cost and bias, the Fixed-Point Designer supports these rounding methods.
| Fixed-Point Designer Rounding Mode | Description | Tie Handling | Cost | Bias |
|---|---|---|---|---|
Ceiling | Rounds to the nearest representable number in the direction of positive infinity. | N/A | Low | Large positive |
Convergent | Rounds to the nearest representable number. | Ties are rounded to nearest even number. | High | Unbiased |
Floor | Rounds to the nearest representable number in the direction of negative infinity. Equivalent to two's complement truncation. | N/A | Low | Large negative |
Nearest | Rounds to the nearest representable number. | Ties are rounded to the closest representable number in the direction of positive infinity. | Moderate | Small positive |
Round | Rounds to the nearest representable number. |
| High |
|
Simplest(Simulink® only) | Automatically chooses between Floor and
Zero to produce generated code that is as
efficient as possible. | N/A | Low | Depends on the operation |
Zero | Rounds to the nearest representable number in the direction of zero. | N/A | Low |
|
Choosing a Rounding Mode for Diagnostic Purposes
Rounding toward ceiling and rounding toward floor are sometimes useful for diagnostic purposes. For example, after a series of arithmetic operations, you might not know the exact answer because of word length limitations, which introduce rounding. If every operation in the series is performed twice, once rounding to positive infinity and once rounding to negative infinity, you obtain an upper limit and a lower limit on the correct answer. You can then decide if the result is sufficiently accurate or if additional analysis is necessary.