0005 — Fixed point: Q20.12 / Q16.16, bit-identical on every target

Choice. fx12/fx16 are C++ value types (zrt::Fx<F>, 32-bit raw) and exact doubles in sim; add/sub wrap, mul/div use 64-bit intermediates (BigInt in sim), sin/cos use a shared 4096-entry table generated by runtime/gen_tables.mjs, sqrt is an integer square root. The ps1 profile compiles number as fx12; literals are quantized with the same rounding in both emitters.

Consequences. zinc test --profile ps1 is byte-identical between sim, macOS and MIPS I under QEMU. NaN and Infinity do not exist in this profile (parseInt(‘x’) gives 0). Transcendentals other than sin/cos/sqrt go through f64 and are quantized.

Edit this page on GitHub ↗