This post describes Floating point and Fixed point.
IEEE754 32-bit floating point (single precision) is represented by 1-bit sign, 8-bit exponent, and 23-bit mantissa.
Ex)
Decimal 85.125
Floating point 0x42AA4000
I will not explain the conversion process in this post, but the conversion requires a lot of processing.
Declaring floating point (float) in a program makes the following difference between MCUs with and without FPUs.
FPU | Processing speed | Code value | Price |
---|---|---|---|
MCU with FPU (with FPU instruction code) | Fast | Small | High |
MCU without FPU (without FPU instruction code) | Slow | Large | Low |
Therefore, there are cases where MCUs without FPUs use a fixed decimal point. I believe that each company uses fixed points with its own set of rules. In this submission, 32-bit fixed-point is expressed as 1-bit sign, 15-bit integer, and 16-bit decimal point (1/65536).
Ex)
Decimal 85.125
Fixed point 85.125×65536 = 0x00552000
Thus, there are the following differences between floating point and fixed point.
Point | Standard | Calculation | Range of expression | Calculation accuracy |
---|---|---|---|---|
Floating point | Standards. | difficult | wide | High |
Fixed point | Each company is different | easy | narrow | Low |
Please note that in the past, MCUs without FPUs were used, so some legacy fixed-point legacy codes may still be present.