Exact rational arithmetic via p-adic numbers — no floating-point errors, ever.
Ostrowski (1916) + Hensel (1904) + Krishnamurthy (1977) → ℚp completes ℚ exactly
Enter any rational numbers (decimals or fractions). Compare exact Hensel code results against IEEE 754 floating-point — see the difference for yourself.
In 1991, a Patriot missile system tracked time in 1/10 second increments using 24-bit binary. Each tick of 0.1 accumulated a tiny rounding error. After 100 hours, the drift reached 0.34 seconds — missing an incoming Scud missile. 28 soldiers died.
Below: 36,000 ticks of 0.1 seconds (1 hour simulation — enough to see the drift).
The p-adic integers ℤp form an infinite regular tree. Each level groups numbers that agree modulo pⁿ. Two numbers are "close" if they share a deep ancestor. This is an ultrametric — every triangle is isosceles.
↕ d(x, y) = p−LCA_level — ultrametric: d(x,z) ≤ max(d(x,y), d(y,z))
Every non-trivial absolute value on ℚ (the rational numbers) is equivalent to exactly one of: the real absolute value (completing to ℝ) or a p-adic absolute value (completing to ℚp). These are the only completions of ℚ. Both are equally fundamental. Current computing uses only ℝ; adding ℚp gives us exactness.
Any root modulo p lifts uniquely to higher powers of p via a constructive algorithm. This means every rational a/b (with p ∤ b) has a unique p-adic expansion computable digit by digit — the foundation for Hensel codes.
H(a/b) = a · b⁻¹ (mod pᵏ) — a single integer. All four
arithmetic operations are exact integer operations modulo pᵏ. Zero rounding error.
Recovery via Extended Euclidean Algorithm.
The p-adic integers form an infinite regular tree. Any finite ultrametric (e.g., a dendrogram from hierarchical clustering) embeds into this tree. This provides natural clustering and distance metrics for exact arithmetic results.
• Denominators must be coprime to the chosen prime p — pick p larger than any expected denominator.
• Irrationals (π, e, √2) require symbolic representation — this system handles rationals exactly.
• Practical use: p = 257 or p = 65537 for general-purpose exact arithmetic.