Improvements in languages, compilers, hardware, and even standards continue to simplify the task of performing mathematical calculations in embedded systems. Even with these improvements, though, the calculations do not always perform as expected.

This paper compares the different types of machine calculations&#151integer, fixed point, and floating point&#151in terms of versatility, accuracy and speed. It looks at the sources of errors for each type and ways to manage them. It covers type conversions, overflow effects, implementation tricks, custom integer sizes, and machine dependencies. It shows how to implement fixed point math using integers and customize it to your needs. The emphasis is on simplicity and practicality. Examples are given in “C”, although the concepts apply equally well to other programming languages.