wire / wire-format / fixed-point
Fixed-point represents real numbers with a fixed number of digits after the radix point. An n-bit fixed-point number with f fractional bits: value = integer / 2^f. Range: -2^(n-f-1) to 2^(n-f-1) - 2^(-f). Common formats: Q15 (16-bit, 15 frac), Q31 (32-bit, 31 frac), Q1.15, Q1.31. Used in DSP, embedded systems, and financial calculations where floating-point is too slow or non-deterministic.
aka: Fixed-point number representation
spec: Fixed-point arithmetic
Fixed-point represents real numbers with a fixed number of digits after the radix point. An n-bit fixed-point number with f fractional bits: value = integer / 2^f. Range: -2^(n-f-1) to 2^(n-f-1) - 2^(-f). Common formats: Q15 (16-bit, 15 frac), Q31 (32-bit, 31 frac), Q1.15, Q1.31. Used in DSP, embedded systems, and financial calculations where floating-point is too slow or non-deterministic.
| field | size | meaning |
|---|---|---|
| Integer part | n-f bits | The whole number part (including sign bit for signed). |
| Fractional part | f bits | The fractional part, scaled by 2^f. |
| Format Qm.n | m+n+1 bits | Qm.n: m integer bits, n fractional bits, 1 sign bit. Total = m+n+1. |
| Q15 (16-bit) | 16 bits | 1 sign + 0 integer + 15 fractional. Range: -1.0 to 0.99997. Resolution: 2^-15. |
| Q31 (32-bit) | 32 bits | 1 sign + 0 integer + 31 fractional. Range: -1.0 to 0.9999999995. Resolution: 2^-31. |
| Q8.24 (32-bit) | 32 bits | 8 integer + 24 fractional. Range: -128 to 127.99999994. Resolution: 2^-24. |
example:
00 00 80 00
Q15 fixed-point: 0.5 = 0x4000, 1.0 = 0x7FFF (max), -1.0 = 0x8000 (min)
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/fixed-point
or /wire-format/fixed-point.json