Conversion Methodology
Our Approach
ConvUnit uses exact mathematical formulas for all conversions. We do not use approximations, lookup tables, or rounded estimates. Every conversion factor is verified against authoritative sources.
There are two types of conversion in ConvUnit:
- Linear conversions — most units (length, weight, area, etc.) use a single multiplication factor
- Non-linear conversions — temperature, shoe size, and fuel efficiency use multi-step formulas
Linear Conversions
For the majority of units, conversion is straightforward multiplication:
target_value = source_value × (source_unit.toBase / target_unit.toBase)
Each unit stores a single toBase value — its ratio to the category's base unit. For example:
- Length: base unit = meters. 1 km = 1000 m, 1 mile = 1609.344 m
- Weight: base unit = grams. 1 kg = 1000 g, 1 lb = 453.592 g
- Data Storage: base unit = bytes. 1 KB = 1024 B, 1 MB = 1048576 B
This approach is exact and produces no intermediate rounding errors.
Non-Linear Conversions
Temperature
Temperature uses Celsius as the base unit with multi-step formulas:
- °C → °F: °F = °C × 9/5 + 32
- °F → °C: °C = (°F − 32) × 5/9
- °C → K: K = °C + 273.15
Shoe Size
Shoe sizes use foot length in centimeters as the intermediate unit:
- US Men: foot_cm = US × 0.838 + 21.64
- US Women: foot_cm = US × 0.838 + 20.8
- UK: foot_cm = UK × 0.838 + 22.0
- EU: EU = (foot_cm + 1.5) × 1.5
- JP: JP = foot_cm × 10
Fuel Efficiency
Fuel efficiency uses km/L as the base unit:
- mpg (US) = 0.425144 × km/L
- L/100km = 100 / km/L (inverse relationship)
Data Sources
Conversion factors are sourced from:
- NIST Special Publication 811 — Guide for the Use of the International System of Units (SI)
- BIPM — International Bureau of Weights and Measures
- ISO 80000 — Quantities and Units international standard
- IEEE/ASTM SI 10 — Standard for Use of the International System of Units
Currency exchange rates are provided by the European Central Bank via the Frankfurter API, updated daily.
Precision & Display
ConvUnit displays results with up to 6 significant figures. Internal calculations use JavaScript's number type (IEEE 754 double-precision), which provides approximately 15-17 significant digits of precision.
For most everyday conversions, this is more than sufficient. For scientific applications requiring arbitrary precision, we recommend using a dedicated arbitrary-precision library.
Testing
All conversion logic is validated by 74 automated tests covering:
- Linear conversions (length, weight, area, volume, etc.)
- Temperature conversions (C ↔ F ↔ K)
- Shoe size conversions (US/UK/EU/JP)
- Slug generation (URL path creation)
- Formatting (significant figures)
Tests run on every commit to prevent regressions.
Update Policy
- Unit definitions: Updated when errors are found or new units are added
- Conversion factors: Never change for existing units (backward compatibility)
- Currency rates: Updated daily via Frankfurter API
- Site structure: Changes are deployed via Cloudflare Workers with zero downtime