So from the research I've done, it looks like the answer is a no, but I figured I'd throw a hail mary and ask here.
Is there a way to set the rounding style for floating point arithmetic (+,-,*,/)?
Note, I am NOT referring to round(), trunc() etc in Math.h
This would be the equivalent of fesetround()
I've already looked through the documentation for AVR-libc as well as a lot of useless google results, and found nada, so it looks like it's not, but again, hail mary.
Then what are you looking for?
Do your calculation in scaled int.
As I stated just below that line, it would be the equivalent of fesetround
That is looking like it's the only way, but I really don't want to. I've had to do that before and it's much slower, as well as much more error prone.
Don´t forget the Arduino hasn't have a FP unit to do this faster.
Can't the same thing be done by checking the sign and then adding or subtracting 0.5 before truncating? You could define some macros that use the ternary operator, for example.
It looks like ARM-based, ESP8266, and ESP32 processors support the 'fenv.h' and 'cfenv' include files. You're out of luck with the AVR processors.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.