It is widely known that float arithmetic takes longer (that is, eats more cycles) than fixed-point (or integer, or bitwise arithmetic), and that surely is something to consider for speed- and time-critical applications.
My question is: supposing I don't have any time-critical need (and I have enough program and RAM memory), should I be worried by any other disadvantage of using float
?
Specifically, I wonder if the processor would be more power-hungry because of those extra CPU cycles.
UPDATE: What will my application do meanwhile?
The only goal of the application is to turn lights on and off (lots of them) based on push-button input. I am using float
to apply filtering to button inputs, in order to debounce the buttons simulating a RC filter + schmitt-trigger. So the loop in pseudo-code would be:
- Read all inputs (digitalRead or direct port access);
- Filter the readings and decide if a button action has been detected;
- Set some control flags that determine which part of the cycle the lights are in;
- Check for elapsed time to actually turn blinkers on and off.
So, since I plan to react to button input as realtime as possible, most time would be spent filtering (that is, performing floating point operations), since direct port access and flag-setting are supposed to be nearly instantaneous, right?
port access and flag-setting are supposed to be nearly instantaneous
- yes direct port access would take place in about 2 clock cycles.