Non-Confidential | PDF version | ARM DUI0475M | ||

| ||||

Home > Floating-point Support > IEEE 754 arithmetic > IEEE 754 arithmetic and rounding |

IEEE 754 defines different rounding rules to use when calculating arithmetic results.

Arithmetic is generally performed by computing the result of an operation as if it were stored exactly (to infinite precision), and then rounding it to fit in the format. Apart from operations whose result already fits exactly into the format (such as adding 1.0 to 1.0), the correct answer is generally somewhere between two representable numbers in the format. The system then chooses one of these two numbers as the rounded result. It uses one of the following methods:

- Round to nearest
The system chooses the nearer of the two possible outputs. If the correct answer is exactly halfway between the two, the system chooses the output where the least significant bit of

`Frac`

is zero. This behavior (round-to-even) prevents various undesirable effects.This is the default mode when an application starts up. It is the only mode supported by the ordinary floating-point libraries. Hardware floating-point environments and the enhanced floating-point libraries support all four rounding modes.

- Round up, or round toward plus infinity
The system chooses the larger of the two possible outputs (that is, the one further from zero if they are positive, and the one closer to zero if they are negative).

- Round down, or round toward minus infinity
The system chooses the smaller of the two possible outputs (that is, the one closer to zero if they are positive, and the one further from zero if they are negative).

- Round toward zero, or chop, or truncate
The system chooses the output that is closer to zero, in all cases.