Introduction to fixed-point numbers
We've worked extensively with binary and BCD numbers throughout this book. Binary is great for math because addition, subtraction, and multiplication are cheap and easy. Division isn't too bad, but more time-consuming. We have only really used BCD numbers for displaying output.
In the previous chapter, we needed to introduce fixed-point numbers. Recall the temperature sensor format:
[15:7] Integer [6:3] fraction * 0.0625 [2:0] Don't Care
If we look at mathematical operations, we know that adding two numbers increases the result size by 1
bit and that to multiply two numbers, we need to add the sizes together. The one question is where the fixed point goes in both cases:
The important thing to remember is that when you're adding two fixed-point numbers, the digit point will remain at the same location. When multiplying...