Unit Conversion Mistakes That Sink Projects: Precision, Rounding and Context
From the Mars Climate Orbiter to a recipe that fails in another kitchen — why unit conversion goes wrong, what exact versus defined factors mean, and how to keep precision honest.
The $327 million unit error
In 1999 NASA lost the Mars Climate Orbiter because one team’s software produced thrust in pound-force seconds and another’s consumed it as newton-seconds. Nothing was miscalculated; a number simply crossed a boundary without its unit. Every unit bug is that bug in miniature: a value travelled further than the context that gave it meaning. The fix is cultural as much as technical — carry units in names (timeout_ms, weight_kg), in types where your language allows, and in every API contract.
Exact, defined and measured factors
Not all conversion factors are equal. Some are exact by definition: one inch is exactly 25.4 mm (since 1959), one pound is exactly 0.45359237 kg, temperatures convert by a formula with no uncertainty. Others are measured constants with finite precision, and some — like "cups" — are not even standardized (a US cup is 236.6 mL, a metric cup 250 mL, a Japanese cup 200 mL). A converter that rounds an exact factor, or treats a regional unit as universal, produces errors that look like precision.
- Temperature is the classic trap: °C to °F is
× 9/5 + 32for a temperature, but just× 9/5for a temperature *difference*. "It warmed by 10 °C" is an 18 °F change, not 50 °F. - Mass vs weight vs force: kilograms are mass, newtons are force; "kgf" exists and confuses everyone.
- Nautical vs statute miles, US vs imperial gallons (a 20% difference), short vs long tons — always check which regional variant a source means.
Rounding: where precision quietly dies
Convert 1 inch to centimeters, round to 2.5, convert back: 0.984 inches. Do that across a multi-step calculation and the error compounds. Rules that hold up: round only at the end, never in intermediate steps; keep at least one more significant figure than the least precise input; and report results with the precision the inputs justify — a measurement of "about 3 feet" is not 91.44 cm, it is roughly 90 cm.
Floating-point adds its own noise: 0.1 + 0.2 is not 0.3 in binary arithmetic. For currency and anything summed over many rows, use decimal types or integer minor units (cents, millimetres) rather than floats.
Data units deserve special suspicion
Is a kilobyte 1000 bytes or 1024? Both, depending on who is talking: storage vendors and the SI say 1000 (kB), operating systems and RAM say 1024 (properly "KiB"). A "500 GB" drive shows as 465 GB in Windows — not a defect, a unit mismatch. Network speeds are in bits (Mbps), file sizes in bytes (MB); a 100 Mbps line moves 12.5 MB per second at best. When you see a data figure with no clear unit convention, assume the ambiguity is real and check.