Zero plus zero equals two.
Not in some toy project. In Berkeley SoftFloat — the IEEE 754 math library reference implementation. It’s inside QEMU and most x86 emulators, and it’s the oracle that hardware teams verify chip designs against.
If you’ve ever emulated a CPU or validated a chip design in the last decade, Berkeley SoftFloat did the floating-point math.
I found seven wrong results across five of six arithmetic operations in the 80-bit extended precision format. The one Intel invented for the x87 FPU in 1980.
Some other fun highlights:
- 0.5 + 0.5 = 3
- A huge finite number plus zero = infinity
- Infinity x 0 = infinity (and no error raised)
- Two tiny numbers added together = zero
These aren’t rounding errors. These are completely wrong answers for valid inputs.
The root cause: the x87’s 80-bit format has an explicit “integer bit” that every other IEEE format hides. This creates encodings — unnormals, pseudo-denormals, pseudo-infinities — where the bit says one thing and the exponent says another. The original 8087 handled all of them correctly. SoftFloat hasn’t since its 2011 rewrite.
Nobody noticed because the test suite has a structural blind spot. The test generator only produces the encodings that SoftFloat itself would output… the “nice” ones where the integer bit is consistent with the exponent. It never generates the inputs that trigger the bugs. I patched the generator to cover the full input space and failures lit up everywhere.
I never would have found any of this if I hadn’t been writing my own floating-point library from scratch. When my results disagreed with SoftFloat, I assumed I was wrong. Over and over. I’d go back to my code, recheck my math, trace through my logic… because the reference implementation couldn’t possibly be wrong. That’s what “reference” means.
But the reference was wrong, and I wasn’t, and suddenly…
Suddenly I was very sad.
SoftFloat is supposed to be “the thing that is correct.” It’s the ultimate tech industry oracle, the final reference on one plus one. TestFloat tests hardware against SoftFloat. FPGA developers validate against SoftFloat.
When your personal deity lies, when addition and subtraction themselves dissemble, the epistemological foundation shifts under you. You can’t trust the thing you trusted, and now you have to ask what else you can’t trust.
What makes my situation lonelier is that finding the bug doesn’t feel like a win, because it shouldn’t have been there in the first place. I wasn’t looking for SoftFloat bugs. No one gives you an award for breaking addition and subtraction. I was trying to validate my own work and the ground moved, and now I just feel like I’m waiting for the next earthquake.