next up previous contents
Next: Precision Errors Up: Simple Input / Output Previous: Precedence Example

 

Cost of Arithmetic Operators

Every operation on a computer has an associated cost. As users, the game we must play is to complete the task in hand whilst minimising the overall cost. The following table gives a very rough guide to the cost of certain operations:

tabular5294

On some machines floating point arithmetic will be quicker than the equivalent integer arithmetic. This is especially true if the machine has a dedicated floating point processor (a maths co-processor.) In general divisions are much slower than multiplications (by a factor of 5 or more). The speed of calculation of exponentiated numbers depends on the exponent and to a certain extent the base. Some REAL exponents, such as the literal 0.5 (square root) are very quick as a special purpose algorithm can be called (SQRT).

Return to corresponding overview page gif


next up previous contents
Next: Precision Errors Up: Simple Input / Output Previous: Precedence Example

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.