IQmath
C2000 Microcontroller Workshop - Numerical Concepts 8 - 17
The IQmath approach enables the seamless portability of code between fixed and floating-point
devices. This approach is applicable to many problems that do not require a large dynamic range,
such as motor or digital control applications.
IQ Fractions: uniform distribution (same precision everywhere)
0
+∞
-∞
Number Line Insight
Distributions
Both floating-point and IQ formats have 2
32
possible
values on the number line
It’s how each distributes these values that differs
Floating-Point: non-uniform distribution (variable precision)
0
+∞
-∞
Traditional “Q” Math Approach
Traditional 32-bit “Q” Math Approach
y = mx + b
Y = ((int64) M * (int64) X + (int64) B << Q) >> Q;in C:
Note: Requires support for 64-bit integer data type in compiler
<< 24
Align Binary
Point for Add
I8 Q24
M
X
B
Y
I8 Q24
I8 Q24
I16 Q48
ssssssssssssssssssI8 Q24
ssssI8 Q48
I16 Q48
sssssssssssssssssI16 Q24 I8 Q24
>> 24
Align Binary
Point for Store