Calculation help
Beavis3215
Posts: 229
in Propeller 1
What is the best way to execute this in C?
elapsed is an integer number of microseconds of 3,000 to 25,000
rpm = 1/(9 * (elapsed / 60,000,000));
elapsed is an integer number of microseconds of 3,000 to 25,000
Comments
rpm = 6666667/elapsed;
True - I recently spent several hours attempting to speed up a couple of time sensitive procedures by simplifying calcs, etc. and the compiler (PropGCC) spit out pretty much the same assembly despite multiple approaches. One important concept is when scaling variables up or down to facilitate integer math using a power of 2 for the mults and divs is very, very fruitful when looking for speed. This has been mentioned multiple times over many years here but is worth repeating.
Mike R...