Skip to content
Zesona

How exact unit conversion actually works

15 October 20262 min readby The Zesona team
convertersprecisionhow-it-works

Type "5 miles to km" into most converter sites and you get back something like 8.046722999999999. That trailing noise is not a rounding choice — it is floating-point error, and it is a sign the site multiplied decimal approximations together and handed you whatever came out.

Zesona's unit converters work differently.

The problem with decimals

Many conversion factors are defined exactly. An inch is exactly 25.4 mm. A pound is exactly 0.453 592 37 kg. A nautical mile is exactly 1852 m. The trouble is that 0.453 592 37 cannot be stored perfectly in binary floating point, so the moment you write it as a double, you have already lost a little precision. Chain a few of those together and the error compounds.

Fractions, not floats

Instead of decimals, each exact factor is stored as a rational number — a whole-number numerator over a whole-number denominator. An inch becomes 127/5 millimetres. A pound becomes 45 359 237 / 100 000 000 kilograms. Arithmetic on fractions is exact: no information is lost along the way.

The calculation runs end to end in that exact form, and the result is rounded once, at the very end, to the number of decimal places you asked for. That is why the answers look "too precise" — they are simply correct, and then rounded deliberately rather than accidentally.

When a factor is not exact, we say so

Not everything can be a clean fraction, and pretending otherwise would be dishonest:

  • A calendar year has no single agreed length in seconds, so time

conversions state the assumption they use.

  • Anything involving pi — radians, some area and volume relationships — is

irrational and cannot be a rational factor.

  • A pixel has no physical size until you choose a resolution, which is why

the pixel converters ask for a DPI instead of silently assuming 96.

The goal is simple: give you the exact answer where one exists, and name the assumption everywhere one is needed.

Try it

Pick any pair and watch the precision hold up:

Every one of them runs in your browser, so the arithmetic happens on your device and nothing is sent anywhere.