Frequently Asked Questions
How much time do math operations take?
Unsigned 8 bit operations are quite fast and floating point is very slow. If
possible consider fixed point instead of floating point. For example instead of
"float cost_in_dollars;" do "long cost_in_cents;". For trig formulas consider a
lookup table instead of real time calculations (see EX_SINE.C for an example).
The following are some rough times on a 20 mhz, 14 bit PIC. Note times will
vary depending on memory banks used.
8 bit add | <1 us |
8 bit multiply | 9 us |
8 bit divide | 20 us |
16 bit add | 2 us |
16 bit multiply | 48 us |
16 bit divide | 65 us |
32 bit add | 5 us |
32 bit multiply | 138 us |
32 bit divide | 162 us |
float add | 32 us |
float multiply | 147 us |
float divide | 274 us |
exp() | 1653 us |
Ln() | 2676 us |
sin() | 3535 us |