Math and Embedded Systems

Many embedded engineers think that floats are no longer useful in embedded systems. They are wrong. Even now, many microcontroller units contain floating point hardware. The alternative is software, which takes a lot of memory and is slow.

Floating point is useful because it is convenient and fast. The problem is, they have limited dynamic range and fractional arithmetic is impossible to perform. This means their performance is limited. But there is another alternative. Most embedded engineers are aware of this. It is called fixed point math.

There is no doubt that integers (floating point math) have a number of advantages. For instance, it is very fast and easy to understand. It can give you a large range but will cost in terms of CPU cycles. Fixed point math is the sweet compromise. If you use fixed point math, you are going to lose some range but in return, you gain precision.

Generally, fixed point math is faster than floating point math. Moreover, if you need speed and use of fractional values, fixed point math is better. Embedded engineers have even started using fixed point math in computation heavy control applications such as proportional integral derivative loops.