So, I'd always had the general idea that floating point and division were slow. But I was curious to see some real numbers. So, I played around a bit.
Because division is theoretically done by a series of repeated subtractions, I expected a large difference in performance when the denominator is small or large. Here is what I found:
Number of microseconds required to perform 255 operations on:
Byte addition: 152
Byte multiplication: 196
Word addition: 224
Word multiplication: 252
Long addition: 388
Long multiplication: 444
Float multiplication: 2,572
Float addition: 2,756
Byte division, large denominator: 3,420
Word division, large denominator: 3,468
Byte division, small denominator: 3,524
Word division, small denominator: 3,700
Float division, small denominator: 7,520
Float division, large denominator: 7,532
Long division, large denominator: 9,852
Long division, small denominator: 11,320
('word' == unsigned int)
So, a few surprises:
Compared to 8-bit math, 16-bit math is not half as fast.
Floating point division is faster than long division. If you have a lot of 'long' divisions inside a loop, you may see a performance gain by copying the variable values to floats before entering the loop.
Floating multiplication is faster than floating addition (though not by much).
Word division in my first test was faster than byte division -- I had cast my numerator as a (byte). When I instead cast it as (word), then byte division became faster than word division (these are the results shown above). Apparently, the compiler uses 'word' internally for division, so casting to (byte) actually slows things down. The fact that byte and word division performance is very very similar supports this theory. So, if you're doing division, there's not much benefit to using an 8-bit integer in favor of a 16-bit integer. Or alternatively, implementing your own 8-bit division routine in assembler may be able to outperform GCC.
The performance difference between small and large denominators is much smaller than I expected (though still measurable).
Denominator size has less of an impact on floats than it does on other data types (in fact, the difference of large vs small denominator in floats is probably statistically insignificant, due to insufficient measurement timing precision).
Executive summary: Use the smallest data type possible; division is slower than floating point.