Main Content

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: Ε(θ^θ).

    • Ε(θ^θ)<0 — The rounding method introduces a negative bias.

    • Ε(θ^θ)=0 — The rounding method is unbiased.

    • Ε(θ^θ)>0 — 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 ModeDescriptionTie HandlingCostBias
CeilingRounds to the nearest representable number in the direction of positive infinity.N/ALowLarge positive
ConvergentRounds to the nearest representable number.Ties are rounded to nearest even number.HighUnbiased
FloorRounds to the nearest representable number in the direction of negative infinity. Equivalent to two's complement truncation.N/ALowLarge negative
NearestRounds to the nearest representable number.Ties are rounded to the closest representable number in the direction of positive infinity.ModerateSmall positive
RoundRounds to the nearest representable number.
  • For positive numbers, ties are rounded to the nearest representable number in the direction of positive infinity.

  • For negative numbers, ties are rounded to the nearest representable number in the direction of negative infinity.

High
  • Small negative for negative samples

  • Unbiased for samples with evenly distributed positive and negative values

  • Small positive for positive samples

Simplest
(Simulink® only)
Automatically chooses between Floor and Zero to produce generated code that is as efficient as possible.N/ALowDepends on the operation
ZeroRounds to the nearest representable number in the direction of zero.N/ALow
  • Large positive for negative samples

  • Unbiased for samples with evenly distributed positive and negative values

  • Large negative for positive samples

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.

See Also

Topics