Convert Metric
Converts a string with imperial units to metric units.
By default, the conversion is casually rounded to four figures with trailing zeros trimmed. The desired number of significant figures can be specified with the optional sig
argument. Trailing zeros can be preserved with an optional strict
flag.
Usage
var convert = ; // returns '60.96 cm'
Spaces are optional.
// returns '91.44 cm'
The appropriate metric unit is chosen automatically.
// returns '1m' (measurements >= 1 m return with m) // returns '99.97 cm' (measurements < 1 m return with cm)
Full and plural unit names are recognized.
// returns '1.52 m'
Fractional measurements are recognized. (Mixed fractions are not yet supported.)
// returns '9.52 mm'
All recognized measurements in a string are converted.
// returns 'Remote Switch, 3.66 m Lead' // returns '2 gauge, 183 cm' // returns '9.52 mm x 24.4 m' //returns '55.4 cm L x 16.0 cm D x 17.7 cm H'
Supported Conversions
- in to mm or cm
- ft to cm or m
- lb to kg