Precision Lab – Floating-Point Arithmetic Step by Step
Step-by-step simulation of IEEE 754 formats (float, double, x87 extended, quad, and arbitrary precision p) compared against exact arithmetic
An interactive floating-point arithmetic simulator that evaluates variables and short programs once in exact mathematics and simultaneously across selected IEEE 754 formats. Operation by operation, it reveals where and why hardware arithmetic diverges from paper-and-pencil calculations — from tiny rounding discrepancies to errors spanning tens of orders of magnitude.
Comparison of exact value against float, double, and p=200 on Rump's polynomial with automatic diagnosis of lost significant digits
Project Overview & Context
Arithmetic inside a CPU's ALU behaves fundamentally differently from mental or paper calculations. While integer limits are relatively transparent (overflow when exceeding fixed bit widths), floating-point representation introduces subtle phenomena that appear as bugs to the user yet represent strictly conforming IEEE 754 behavior. Precision Lab lets users step through operations, track significant digits, inspect aligned significands and rounding bits (guard, round, sticky), sweep across precision p, and test semantics-preserving expression rewrites.
Key Features & Capabilities
IEEE 754 Formats & Arbitrary Precision
Side-by-side evaluation in binary16, bfloat16, binary32 (float), binary64 (double), x87 80-bit extended, binary128 (quad), and custom precision p (1 to 100,000 bits) across five IEEE rounding modes.
Step Table, Diagnosis & Bit-by-Bit View
Reports rounding direction, significant digits, IEEE flags, and root causes (representation error, absorption, catastrophic cancellation ×κ, inherited error, overflow/underflow, double rounding) with bit-level significand alignment and guard/sticky bits.
Precision Sweep Across p
Runs the program across a range of precisions p (e.g., 1–1000 bits) in a background Web Worker, plotting error and significant digits against p and pinpointing sharp convergence thresholds (such as p = 122 for Rump's polynomial).
Semantics-Preserving AST Rewrites
An interactive AST view offers algebraically verified transformations (commutativity, associativity, factoring, power expansion) and compares rounded results before and after rewriting.
25 Curated Examples with Literature References
A structured learning path in six groups: from 0.1 + 0.2 == 0.3, exact integer limits, and Kahan summation to Rump's polynomial, Muller's recurrence, Kahan's needle triangle, and x87 double rounding, complete with verified DOI citations.
Educational Value & Pedagogical Context
In software testing, scientific computing, and control systems, developers regularly encounter mathematically sound formulas that yield completely inaccurate results on a CPU — or floating-point comparisons that fail due to representation error. Precision Lab demonstrates that this is not a processor bug, but a deterministic consequence of finite IEEE 754 binary arithmetic, teaching students how to diagnose precision loss, choose sound comparison tolerances, and rewrite expressions into numerically stable forms.
