Module dsp::fixed
DSP / Fixed-Point Arithmetic (Q8.24) Q8.24: 8 integer bits, 24 fractional bits, stored as a 32-bit signed int. Matches 24-bit audio sample depth for sub-sample precision.
Newtypes
| Fixed |
Functions
| fixed_from_int | Convert integer to Fixed (shift left by 24). |
| fixed_from_float | Convert double to Fixed (multiply by 2^24 and truncate). |
| fixed_to_int | Convert Fixed to integer (arithmetic right shift by 24 — rounds toward -∞). |
| fixed_to_float | Convert Fixed to double. |
| fixed_add | Addition and subtraction (same scale, just add/sub the raw values). |
| fixed_sub | |
| fixed_mul | Multiplication: (a * b) >> 24 using 64-bit intermediate. |
| fixed_div | Division: (a << 24) / b using 64-bit intermediate. |
| fixed_abs | Absolute value. |
| fixed_neg | Negation. |
| fixed_sqrt | Integer square root (Newton-Raphson, 4 iterations). Argument must be >= 0. |
Macros
| FIXED_ONE | 1.0 in Q8.24 |
| FIXED_HALF | 0.5 in Q8.24 |
| FIXED_PI | π ≈ 3.14159265 in Q8.24 (3.14159265 * 16777216 ≈ 52707178) |