Q is a fixed point number format where the number of fractional bits (and optionally the
number of integer bits) is specified. For example, a Q15 number has 15 fractional bits; a
Q1.14 number has 1 integer bit and 14 fractional bits. Q format is often used in
hardware that does not have a floating-point unit and in applications that require
constant resolution.
Q format numbers are (notionally) fixed point numbers (but not actually a number itself);
that is, they are stored and operated upon as regular binary numbers (i.e. signed
integers), thus allowing standard integer hardware/ALU to perform rational number
calculations. The number of integer bits, fractional bits and the underlying word size are
to be chosen by the programmer on an application-specific basis - the programmer's
choices of the foregoing will depend on the range and resolution needed for the numbers.
The machine itself remains oblivious to the notional fixed point representation being
employed - it merely performs integer arithmetic the way it knows how. Ensuring that the
computational results are valid in the Q format representation is the responsibility of the
programmer.
The Q notation is written as Qm.n, where:
• Q designates that the number is in the Q format notation - the Texas Instruments
representation for signed fixed-point numbers (the “Q” being reminiscent of the
standard symbol for the set of rational numbers).
• m is the number of bits set aside to designate the two's complement integer portion of
the number, exclusive of the sign bit (therefore if m is not specified it is taken as
zero).
• n is the number of bits used to designate the fractional portion of the number, i.e. the
number of bits to the right of the binary point. (If n = 0, the Q numbers are integers -
the degenerate case).
Note that the most significant bit is always designated as the sign bit (the number is
stored as a two's complement number) in order to allow standard arithmetic-logic
hardware to manipulate Q numbers. Representing a signed fixed-point data type in Q
format therefore always requires m+n+1 bits to account for the sign bit. Hence the
smallest machine word size required to accommodate a Qm.n number is m+n+1, with the
Q number left justified in the machine word.
For a given Qm.n format, using an m+n+1 bit signed integer container with n fractional
bits:
• its range is [-2
m
, 2
m
- 2
-n
]
• its resolution is 2
-n
Integer square root
Kinetis KE1xZ256 Sub-Family Reference Manual, Rev. 3, 07/2018
92
NXP Semiconductors
Summary of Contents for Kinetis KE1xZ256
Page 2: ...Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 2 NXP Semiconductors...
Page 178: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 178 NXP Semiconductors...
Page 356: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 356 NXP Semiconductors...
Page 410: ...Interrupts Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 410 NXP Semiconductors...
Page 604: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 604 NXP Semiconductors...
Page 634: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 634 NXP Semiconductors...
Page 674: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 674 NXP Semiconductors...
Page 820: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 820 NXP Semiconductors...
Page 1030: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 1030 NXP Semiconductors...
Page 1052: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 1052 NXP Semiconductors...
Page 1066: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 1066 NXP Semiconductors...
Page 1268: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 1268 NXP Semiconductors...
Page 1314: ...Usage Guide Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 1314 NXP Semiconductors...
Page 1316: ...Kinetis KE1xZ256 Sub Family Reference Manual Rev 3 07 2018 1316 NXP Semiconductors...