Q Number Format¶
Encode binary fixed-point values as stored integers with an implicit power-of-two scale, using a Q notation that declares fractional bits, integer width, and signedness while keeping vendor sign-bit conventions explicit.
Core Idea¶
Q number format is a notation and interpretation scheme for binary fixed-point values. A stored integer N represents the real value N * 2^(-n), where n is the declared number of fractional bits. A fuller Qm.n surface also declares an integer-width field, and an unsigned prefix may indicate unsigned storage. The binary point is implicit: the same bit pattern represents different real values under different n. Texas Instruments documentation describes Q format as rational encoding with a fixed power-of-two scale and catalogs several incompatible m.n conventions.[1]
The notation is not globally uniform. In one widespread Texas Instruments convention, signed Qm.n excludes the sign bit from m, so total width is 1+m+n. In an ARM-style convention, m includes the sign bit and total width is m+n. Short Qn commonly states only fractional bits, leaving word width and signedness to the type or register. Therefore Q7.8 cannot be decoded safely without the convention. A reference-grade record writes the vendor or standard, total width, signedness, two's-complement assumption, fractional count, range, and resolution.
For a signed w-bit two's-complement container with n fractional bits, representable values range from -2^(w-1-n) through 2^(w-1-n)-2^(-n), and resolution is 2^(-n). Encoding a real value multiplies by 2^n, then applies a declared rounding rule and handles overflow through rejection, wraparound, saturation, or wider intermediate storage. Decoding interprets the stored signed or unsigned integer and multiplies by 2^(-n). The format is exact for values on that grid but quantizes other values.
Arithmetic must track scale. Addition and subtraction are direct only when operands have compatible fractional counts and widths; otherwise an operand is rescaled with a rounding policy. Multiplication of Qn values naturally produces 2n fractional bits in the full product and must be shifted or reinterpreted to return to the target scale. Division requires the complementary prescaling and must avoid overflow. Yates gives a concise technical treatment of these fixed-point scaling and arithmetic rules.[2] CMSIS-DSP documentation distinguishes Q7, Q15, and Q31 data and uses wider accumulators in many operations, illustrating that a Q surface carries representation, not a complete arithmetic-safety policy.[3]
The candidate is distinct from Extended-Precision Floating-Point Format, which stores an exponent and variable scale, and from Signedness, which controls only interpretation of the high bit and range. It is not q-Analog or L-notation. Encoding and Decoding is the strict parent because Q format pairs a transformation from real values to scaled integer codes with a recovery rule, conditional on a shared format declaration. Resolution, range, vendor convention, and scale-tracking give the node autonomous computer-arithmetic structure.
Structural Signature¶
- The storage integer. A fixed-width binary word is interpreted as signed two's complement or unsigned.
- The fractional-bit count.
nfixes the implicit scale2^(-n)and quantization step. - The integer-width field.
mdescribes magnitude or signed integer width under a named convention. - The convention source. TI, ARM, or another documented notation determines whether
mincludes the sign bit. - The total word width. Explicit width prevents omitted bits from being inferred incorrectly.
- The representable range. Signedness, width, and scale determine minimum and maximum values.
- The encoding rule. Scaling, rounding, and overflow handling map a real value to stored bits.
- The decoding rule. Integer interpretation and inverse scale recover the represented grid value.
- The arithmetic scale ledger. Operations propagate fractional bits and intermediate width.
- The error policy. Quantization, rounding, saturation, wrapping, and overflow are separately recorded.
What It Is Not¶
- Not floating point. No stored exponent changes scale dynamically.
- Not a value without metadata. Bits alone do not reveal
n, signedness, or convention. - Not one universal
Qm.nsyntax. Sign-bit counting differs among sources. - Not Signedness. Signedness is one component of the format.
- Not Decimal. The implicit radix scale is binary, normally a power of two.
- Not q-Analog. The mathematical deformation parameter
qis unrelated. - Not arithmetic safety by itself. Width growth, rounding, and saturation must be specified separately.
Scope of Application¶
Q format is literal when a binary integer word is paired with an implicit power-of-two scale and a declared width, signedness, and notation convention.
- Digital signal processing. Storing coefficients, samples, and intermediate values without floating-point hardware.
- Embedded control. Choosing deterministic fixed-point scales for sensors and actuators.
- Microcontroller interfaces. Decoding register values documented in Q notation.
- Audio and image processing. Balancing dynamic range and fractional resolution.
- Machine-learning inference. Representing quantized activations and parameters when the actual Q convention is declared.
- Hardware design. Allocating word width and binary-point position across datapaths.
- Numerical verification. Proving overflow and error bounds for fixed-point pipelines.
- Interchange documentation. Preventing vendor-convention mismatch at software and hardware boundaries.
Clarity¶
A clear declaration states w, m, n, signedness, two's-complement or other integer coding, whether m includes the sign bit, scale, range, resolution, rounding mode, overflow mode, and endianness if raw bytes are exchanged. It gives at least one bit-pattern example. Short Q15 is not expanded unless container width is known. Arithmetic documentation states input and output formats and accumulator width for every operation. Conversion tests include zero, one quantum, largest positive, most negative, half-way rounding, and overflow. Hex notation is not treated as a separate numerical value from the same stored bits.
Manages Complexity¶
Q notation compresses several representation choices into a short format label and enables integer hardware to perform fractional computation. Power-of-two scaling turns many conversions into shifts, while fixed resolution supports deterministic error analysis. Compression creates interface risk: the same label can count the sign bit differently, omitted word width can hide range, and an intermediate product can overflow despite valid inputs. The abstraction manages that complexity when the compact surface expands into a complete format contract and an arithmetic scale ledger. It fails when Q notation is used as an informal decoration on raw integers.
Abstract Reasoning¶
- Identify the notation authority and whether
mincludes the sign bit. - Declare storage width, signedness, and the fractional-bit count.
- Compute the scale, resolution, and exact representable range.
- Map the source value to a scaled integer using the selected rounding rule.
- Apply overflow handling and encode the result in the declared integer representation.
- Decode by signed or unsigned interpretation followed by inverse scaling.
- For addition, align fractional counts and guard against width overflow.
- For multiplication or division, derive intermediate scale and width before rescaling.
- Bound quantization and rounding error across the operation chain.
- Verify boundary bit patterns and document every interface conversion.
Knowledge Transfer¶
Q format transfers the idea that a number representation is code + shared scale + interpretation rules, not bits alone. The pattern applies to decimal fixed-point money, block floating point, physical-unit registers, and quantized models. What does not transfer is the exact sign-bit convention or power-of-two scaling. The entry also illustrates metadata debt: a short notation saves space locally but becomes dangerous when the convention is omitted at an interface.
Examples¶
Canonical¶
In a signed 16-bit two's-complement container with 8 fractional bits, the stored integer 384 represents 384/256 = 1.5. Resolution is 1/256. Under a convention that excludes the sign bit from m, this may be described as Q7.8; under a convention that includes it, Q8.8. The bits and numerical value are identical, but the label differs. A decoder given only Q7.8 cannot safely infer width without the convention.[1]
Mapped back: real 1.5 + signed 16-bit Q8 scale → multiply by 256 → store integer 384 → decode by 2^-8 → same grid value.
Applied / In Practice¶
Two Q15 signed samples are multiplied. The full integer product has twice the fractional count and needs a wider accumulator. To return to Q15, the pipeline rounds and shifts by fifteen bits, then saturates if the scaled result exceeds the target range. Merely multiplying two 16-bit words and keeping the low 16 bits would corrupt scale and overflow behavior. CMSIS-DSP's Q data types and accumulator conventions exemplify why the format and operation contract must travel together.[3]
Mapped back: Q15 operands → wide 30-fraction-bit product → declared rounding and rescale → saturation → Q15 result with bounded error.
Structural Tensions¶
- Compact label vs. convention ambiguity.
Qm.nis concise but sign-bit counting varies. Diagnostic: Can total width be computed unambiguously from the declaration? - Fractional precision vs. dynamic range. More fractional bits improve resolution while shrinking magnitude range. Diagnostic: Which worst-case input sets
m? - Integer efficiency vs. scale bookkeeping. Hardware operations are cheap while metadata errors are costly. Diagnostic: Is every intermediate fractional count recorded?
- Exact grid vs. real-value quantization. Grid values are exact but other values round. Diagnostic: What error bound and tie rule apply?
- Valid operands vs. overflowing result. Input range safety does not imply product safety. Diagnostic: What accumulator width and saturation policy are used?
- Shared bits vs. differing interpretation. One word can encode unrelated values under other formats. Diagnostic: Does the interface carry signedness and Q metadata?
- Vendor practice vs. portable specification. Local conventions work until systems meet. Diagnostic: Is the notation authority named at each boundary?
Structural–Framed Character¶
The structure is storage integer, scale, fractional count, width, signedness, encoding, decoding, range, and arithmetic scale propagation. The frame is TI or ARM notation, processor type, rounding, saturation, endianness, and application. A different label can preserve the same bit-to-value mapping; changing n changes the represented value even if bits stay fixed.
Structural Core vs. Domain Accent¶
The transferable core is discrete code + implicit scale + shared convention ↔ recoverable numerical value. The domain accent is binary fixed point, Q labels, fractional bits, two's complement, shifts, saturation, and DSP arithmetic. Remove the accent and Encoding and Decoding remains; retain it and Q Number Format is autonomous.
Instantiates / Related Primes¶
Encoding and Decoding is the strict parent by specialization. Q format encodes a real-grid value as a scaled integer bit pattern and decodes it through signedness and inverse power-of-two scaling. The parent is broader and does not prescribe numbers or fixed point.
The prospective workspace queue contains one strict upward edge to prime:encoding_and_decoding. No live DAG mutation is authorized.
Relationships to Other Abstractions¶
Current abstraction Q Number Format Domain-specific
Parents (1) — more general patterns this builds on
-
Q Number Format is a kind of Encoding And Decoding Prime
Encoding and Decoding is the strict parent by specialization.Q format encodes a real-grid value as a scaled integer bit pattern and decodes it through signedness and inverse power-of-two scaling. The parent is broader and does not prescribe numbers or fixed point. The prospective workspace queue contains one strict upward edge to
prime:encoding_and_decoding. No live DAG mutation is authorized.
Hierarchy path (1) — routes to 1 parentless root
- Q Number Format → Encoding And Decoding → Transformation → Function (Mapping)
Neighborhood in Abstraction Space¶
Q Number Format sits in a sparse region of the domain-specific corpus (85th percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.
Family — Unclustered & Miscellaneous (1565 abstractions)
Nearest neighbors
- Signedness — 0.83
- Integer Overflow — 0.82
- Offset binary — 0.81
- Signed number representations — 0.79
- Division Algorithm — 0.79
Computed from structural-signature embeddings · 2026-09-08
Not to Be Confused With¶
- Floating-Point Format. Stores an exponent and variable scale.
- Signedness. Determines interpretation and range but not fractional scaling.
- Integer Format. Equivalent only when the fractional count is zero.
- Block Floating Point. Shares an exponent across a block rather than fixing one implicit binary point.
- q-Analog. Mathematical construction unrelated to computer Q notation.
- Decimal Fixed Point. Uses a base-ten scale.
- Quantization Scheme. Broader mapping that may use affine zero points or nonuniform levels.
References¶
[1] Texas Instruments, How to Read and Interpret Digital Temperature Sensor Output Data, application note SBAA588A, revised January 2025, section 1.2 Q Format, https://www.ti.com/lit/an/sbaa588a/sbaa588a.pdf. registry ↩a ↩b
[2] Randy Yates, Fixed-Point Arithmetic: An Introduction, Digital Signal Labs technical note (2007), https://www.digitalsignallabs.com/fp.pdf. registry ↩
[3] Arm, CMSIS-DSP Software Library, fixed-point Q7, Q15, and Q31 data types and functions, https://arm-software.github.io/CMSIS-DSP/main/. registry ↩a ↩b