We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
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?
I've found that if I use floating points (which I'm not doing for microcontrollers - at least not yet), then there's a difference between when I ...
#include <math.h>
... and when I forget to do that.
It usually solves my problems when I add the above mentioned #include.
-You probably already did, but I mention it just in case...