Why Your Calculator Is Lying to You
Open any language. Type 0.1 + 0.2. The answer is 0.30000000000000004. This is not a bug. This is IEEE 754.
And How Digital Circuitality Tells the Truth
Open any programming language. Type 0.1 + 0.2. The answer is 0.30000000000000004.
This is not a bug. This is IEEE 754 — the standard that every computer on Earth uses for decimal math. It's been this way since 1985. Every language — Python, JavaScript, Rust, C++, Java — produces this result. And every programmer eventually learns to "just deal with it."
But what if you're building a flight computer? A medical device? A financial system? "Just deal with it" is not an engineering answer. It's a prayer.
The Problem Nobody Talks About
When Boeing designs a flight control system, they don't use Python floats. When NASA calculates trajectories, they don't "hope" the rounding works out. When banks process transactions, they don't use double.
These systems use fixed-point arithmetic — integers multiplied by a scale factor. Instead of 3.14, they store 3140. Instead of $19.99, they store 1999 cents. No floating point. No rounding surprises. Exact.
But this pattern is informal. It's a convention, not a language feature. The programmer has to remember the scale factor, handle the conversions manually, and test obsessively because the language offers no guarantees.
What If the Language Enforced It?
This is what PCD does with Closure Domains.
In PCD, every variable lives inside a declared domain — a numeric range that defines what values are valid. And when you need "decimal" math, you don't use floats. You declare your precision:
PC scientific_calculator {
// The engineer DECLARES: "I need π with 6 decimal places"
domain PI: Range [3141592, 3141593];
// All calculations use integers scaled by 10⁶
// No IEEE 754. No rounding surprises.
// Error: ±0.0000005 — KNOWN and DECLARED
}The key insight: π is an irrational number — it has infinite decimals. An infinite value cannot exist in a closed circuit. So the engineer declares which π they need. π with 3 decimals (3141) for a school calculator. π with 15 decimals (3141592653589793) for NASA. The precision IS the domain boundary.
Three Levels of Math in Digital Circuitality
Approach Type Error Certification
───────────────────── ───────────── ───────────────── ─────────────
Integer arithmetic U8, I64 Zero — exact Φ_c = 1 ✓
Scaled integers I64 + scale Declared Φ_c = 1 ✓
Floating point F64 IEEE 754 rounding Φ_c = CONTRACTThe first two give you full certification. The third gives you convenience at the cost of predictability.
The Engineer's Mindset
This is the fundamental shift: PCD programmers are not coders. They are circuit engineers.
A coder writes velocity = distance / time and hopes the types work out.
An engineer writes:
domain velocity: Range [0, 900]; // my circuit accepts [0, 900]
domain distance: Range [0, 20000]; // bounded input
domain time: Range [1, 86400]; // never zero (prevents division by zero)
domain scale: Range [1000, 1000]; // 3 decimal places of precision
fn calculate_velocity(dist, t) {
// dist and t are scaled ×1000
// Result is in [0, 900000] (velocity × scale)
return (dist * scale) / t;
}The engineer KNOWS:
The input ranges (declared domains)
The precision (declared scale)
The error tolerance (±0.001 from the scale factor)
That division by zero is impossible (time ≥ 1)
That the circuit closes (Φc = 1)
The coder knows none of this. The coder discovers it at 3 AM when production crashes.
Certified Math — Any Function, Any Precision
Logarithms, trigonometry, square roots — all implementable as certified polymers using Taylor series, CORDIC, or Newton's method with only core monomers (ADD, SUB, MUL, DIV):
// ln(x) via Taylor series — all integer arithmetic
// Scale: ×1000000 (6 decimal places)
// ln(2) = 693147 (represents 0.693147)
PC certified_ln {
domain input: Range [500000, 2000000]; // [0.5, 2.0] × 10⁶
domain output: Range [-693147, 693147]; // ln range × 10⁶
fn ln_scaled(x) {
// Taylor: ln(1+t) = t - t²/2 + t³/3 - t⁴/4 + ...
// Using only ADD, SUB, MUL, DIV (core monomers)
// Φ_c = 1 guaranteed
}
}This is not theoretical. Every bank in the world does transaction math this way. Every embedded system does sensor math this way. PCD makes it a first-class language feature with compiler verification.
The Circuit Is Closed. The Truth Is Known.
When your program compiles in PCD:
You know the precision of every calculation
You know the error bounds of every result
You know that no value exceeds its declared domain
You know that the behavior is identical on every machine
Your calculator isn't lying to you anymore.
This is Part 4 of a series. Part 1: What if Software Worked Like DNA? | Part 2: AI Safety with Policy Circuits | Part 3: The BPU — Hardware That Says No