I am developing an AVR platform and I have a question. I do not want the floating point library to be associated with my code, but I like the concept of having analog values in the range 0.0 ... 1.0 instead of 0 ... 255 and 0 ... 1023, depending on the even, regardless of whether I use whether I port as input or as output.
So, I decided to multiply the arguments of the I / O function by 1023.0 and 255.0, respectively. Now, my question is: if I implement a division like this:
#define analog_out(port, bit) _analog_out(port, ((uint8_t)((bit) * 255.0)))
will GCC (with the -O3 flag enabled) optimize compile-time floating-point multiplication known at compile time and converted to an integral type into whole operations? (I know that when using these macros with inconsistent arguments, optimization is impossible, I just want to know if this will be done in another case.)
user529758
source
share