armstm32fpu

STM32H753 (ARM Cortex M7) rounding mode


The Cortex M7 provides in the register FPSCR the bits Rmode to set the rounding mode of the FPU.

I don't understand what this means exactly.

I guess it refers to the rounding of a floating point instruction since it cannot usually be exact ? But then what the different rounding modes mean ? I understand "round to nearest" but what "round to infinity" or "to zero" mean ?


Solution

    1. Rounding to positive infinity means that the result of rounding is always larger than the rounded value. Same with negative infinity (values will always be smaller)
    2. Rounding to zero: values are rounded towards zero. 3.1, 3.2, -3.9, 3.9 will be rounded to -3 or 3 depending on the sign.
    3. GCC doc: It should be used unless there is a specific need for one of the others. In this mode results are rounded to the nearest representable value. If the result is midway between two representable values, the even representable is chosen. Even here means the lowest-order bit is zero."