On this page
The unit converter multiplies by a factor stored next to the unit, or it runs the temperature formulas. It does not look up a measurement, and it does not leave the browser. If you need the number someone will type into a form, use the value the function returns, not a proverb.
Input
Output
Input
Output
Five conversions, run in code
convertUnits produced these raw values. formatConversionResult is what the page is written to display.
| Input | Raw result | Displayed | | --- | --- | --- | | 1 inch to centimeters | 2.54 | 2.54 | | 100 kilometers to miles | 62.13711922373339 | 62.137119 | | 32°F to Celsius | 0 | 0 | | 100°C to Fahrenheit | 212 | 212 | | 1 kilogram to pounds | 2.2046226218487757 | 2.204623 |
The inch factor is the defined 2.54 cm relationship. The mile factor in the same file is 1609.344 meters. 100 kilometers is 100,000 meters, and 100000 / 1609.344 is the raw mile value above, 62.13711922373339. One hundred kilometers is not a tidy 62 miles. The display keeps six digits after the decimal for a value in this range, which is why you see 62.137119 and not the full raw float.
The kilogram line is the one to be careful with. The pound is 0.45359237 kilograms in this file, so one kilogram is 1 / 0.45359237 pounds. The raw product is 2.2046226218487757 and the display rounds to 2.204623. If a specification asks for more digits than the screen shows, do not copy the screen and then add zeros. The extra digits were not there.
Temperature is not a factor. Fahrenheit to Celsius subtracts 32 and multiplies by 5/9. 32°F is the freezing point of water on that scale, and the function returned 0. Celsius to Fahrenheit multiplies by 9/5 and adds 32. 100°C returned 212. Those two points are the easy checks. A middle value such as 20°C is 68°F by the same formula. I did not need a second call to know that arithmetic, and the page uses that arithmetic.
What the categories are
The file groups length, weight, volume, temperature, area, speed, time, pressure, energy, and data. Length, weight, and the rest of the linear groups convert by factors into a base unit and back out. Temperature is the exception, through Celsius.
The same identity is a no-op: converting a unit to itself returns the input. An unknown unit id returns an error instead of a guessed factor.
Numbers whose absolute value is above 1e15 are rejected as overflow, on the way in and on the way out. The error text is "Value is too large or too small to convert accurately." Empty input says "Enter a value to convert." A word instead of a number says "Enter a valid number." Commas in the typed text are stripped before parse, so 1,000 can be a thousand. A thousands separator is not a decimal comma. 1,5 becomes 15 after the comma is removed, which is not one and a half.
Mistakes
Dividing by 1.6 and calling it a mile is the common shortcut. 100 / 1.6 = 62.5. The converter's displayed value is 62.137119. The shortcut is fine for a glance and wrong for a distance you will publish.
Reading 2.2 pounds per kilogram is the same kind of shortcut. The display here is 2.204623. For a person's weight the difference is small. For a shipping limit written on a form, use the function.
Mixing prefixes is a different error. A kilometer is 1,000 meters in this table. A data kilobyte in casual speech is sometimes 1,000 and sometimes 1,024. Check the unit name on the control before you trust a "kilo."
Temperature is where mental math slips. Subtracting 32 without the 5/9, or adding 32 without the 9/5, will not hit 0 and 212 on these two checks. If those two checks fail, the formula in front of you is not the one in the tool.
Limits
The page has no instrument and no calibration. It will convert 1 inch to 2.54 centimeters even if your ruler is worn.
It does not convert currencies. A dirham amount is the currency converter, which fetches a USD rate table and does not send the amount. It does not do percentages. "15 percent off 200" is the percentage calculator. It does not count days between dates. That is the age calculator.
The common-conversions row for length includes the label "1 inch = 2.54 cm". That row calls the same function with the value 1. It is not a second formula.
Display rounding is part of the product. The kilogram row above is the proof. Quote the raw value if the rounded one is not enough, and say that you did.

