A result of 5.91 feet does not mean 5 feet 91 inches, and 5.10 feet does not mean 5 feet 10 inches. That is the representation problem I wanted to unpack when looking at a meters-to-feet converter: a correct scalar conversion can still be misunderstood if the output unit is not explicit.
This comes up constantly with height. A JavaScript calculation returns an ordinary decimal number, while readers may expect a compound expression containing two different units. Those are different output formats, and the conversion page implements only the first.
Convert One Length Unit into Another
The page uses a shared unit table rather than a special height formula. The relevant scales are one meter per meter and 0.3048 meters per foot.
The shared function first converts the source value to meters and then divides by the destination scale:
export function convertLength(value, fromKey, toKey) { const meters = (Number(value) || 0) * (lengthUnitMap[fromKey] || 0); return lengthUnitMap[toKey] ? meters / lengthUnitMap[toKey] : 0; } For a source value already in meters, the first multiplication leaves the magnitude unchanged. Dividing by 0.3048 gives the number of feet.
The fixed-pair page selects m as its source key and ft as its destination key. Its category configuration supplies the length conversion function and its rounding helper. The same calculation path is used for either an entered value or a reference-table value.
This is a scalar conversion. It neither knows that 1.8 meters might describe a person nor decides that a person's height should be written using two unit symbols. Keeping those responsibilities separate makes the implementation easier to inspect.
It also prevents an implicit format change based on magnitude. A mountain altitude and a person's height both remain lengths in feet; the application does not silently switch to a different notation when the number becomes small enough to look like a human height.
The Fractional Part Is Still Measured in Feet
The shared rounding helper keeps at most six decimal places. For 1.8 meters, the result is 5.905512 feet.
The digits after the decimal point represent a fraction of one foot. They are not an inches field. A compound representation would take the whole-foot part and convert the remaining fractional foot to inches, using twelve inches per foot.
For this example, the remainder is approximately 0.905512 feet. Multiplying that remainder by twelve gives about 10.866 inches, so the same length can be described as roughly 5 feet 10.9 inches.
That explanation is arithmetic about the result, not a feature hidden in the source. The current component does not contain a feet-and-inches formatter. Its English explanatory content mentions the compound equivalent, but the editable result remains a decimal number of feet.
This distinction also works in reverse. Entering 5.10 into a decimal-feet field supplies 5.1 feet, not 5 feet 10 inches. Five feet ten inches is approximately 5.833333 feet.
I would not try to solve the ambiguity by guessing what a user meant from the number of decimal digits. The values 5.1 and 5.10 are numerically identical, and a standard number input does not preserve a separate “inches” interpretation. A compound input would need its own controls or an explicit parser.
Show the Unit Wherever the Value Can Be Edited
The pair-page component derives labels from its category and unit keys:
const fromUnitLabel = computed(() => pair.value ? t(`${categoryConfig.value.i18nKey}.units.${pair.value.from}`) : "", ); const toUnitLabel = computed(() => pair.value ? t(`${categoryConfig.value.i18nKey}.units.${pair.value.to}`) : "", ); Those labels are important because both numeric fields are editable. After the user changes the feet field, it becomes the authoritative measurement and the meters field is recalculated from it.
The reverse synchronization actually swaps the source and destination keys:
fromValue.value = categoryConfig.value.round( categoryConfig.value.convert(toValue.value, pair.value.to, pair.value.from), ); Nothing in that expression interprets an embedded inches value. It is the inverse scalar conversion, followed by the same six-decimal rounding policy.
There is a synchronization detail worth keeping with that code: both field watchers run with flush: "sync", and both conversion functions check an isSyncing flag. While one function writes the opposite field, the flag prevents its watcher from immediately converting the rounded value back again. Without that guard, one edit could trigger a round trip and replace the user's original measurement with a rounded reconstruction.
The reference table uses fixed inputs of 1, 5, 10, 25, 50, and 100. It applies the same category conversion and rounding functions as the editable fields. That consistency is useful: the table is not a separately maintained collection of approximate answers.
However, those generic sample values are not a complete height chart or a domain-specific altitude reference. The data pipeline is shared across pair pages, so its convenience should not be confused with specialized measurement knowledge.
Rounding a Compound Display Would Need Another Policy
If I added a feet-and-inches output, I would need to define how inches are rounded and how overflow carries into feet. A rounded result of twelve inches cannot remain attached to the previous whole-foot value without normalization.
For example, 1.8287 meters is just under six feet. Splitting it into whole feet and fractional inches gives five feet and about 11.996063 inches. Rounding the inches to one decimal place produces 12.0, so a normalized display would be 6 feet 0.0 inches, not 5 feet 12.0 inches. I would calculate that display from the unrounded conversion rather than rounding decimal feet first and introducing another rounding step.
That is a proposed formatting policy, not behavior in the current component. The existing decimal output has its own numerical limits: six decimal places are not six significant figures, and a displayed value should not imply more certainty than the input measurement had. For instance, 0.0000001 meters rounds to zero feet with this helper. The exact conversion factor does not make the rounded result lossless or perfectly reversible.
Input validation is another separate responsibility. Both fields specify min="0", but the component's validation handler runs on blur: negative or non-finite values are rejected and the edited field is reset to zero. The synchronous watchers do not wait for that validation before converting an edit, so the minimum is not a guarantee that every intermediate result is nonnegative.
A blank field has a different outcome. Number("") is zero, so it passes that validation check and converts to zero in the helper. That is coercion, not a "measurement required" rule. For a form where an omitted measurement must remain distinct from a measured zero, I would add explicit empty-input handling rather than relying on numeric conversion.
The helper uses the ordinary foot scale of 0.3048 meters. It does not infer a specialized surveying convention, interpret aviation altitude references, or supply uncertainty estimates. It converts the scalar under the unit definitions actually in its table.
For an interface test, I would verify that the result says feet, that 1.8 meters produces 5.905512, and that editing that result performs a decimal reverse conversion. Those checks target the actual representation contract rather than a familiar but unsupported feet-and-inches display.
I turned this scalar conversion into a small free tool: Meters to Feet Converter.

