This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Rounding floats to integers on Cortex-M4

I've encountered an odd problem on STM32F4xx CPU with hardware FPU enabled:

When rounding floats to integers, compiler always uses VCVT (round towards zero) instruction instead of VCVTR (round using rounding mode register settings).

There are compiler options for various IEEE compatibility modes, some of them explicitly define "round to nearest" behaviour, but it seems to be ignored.

Even worse, FLT_ROUNDS in float.h  is defined as floats are rounded, but they're truncated.

fpgetround() and fpsetround() do not work right either.

Any ideas?

0