Engineering functions

CONVERT

Matches all 33,977 recorded answers

Recorded: 33,972 in the answer bank and 5 workbook cells. How we measure this · See the Rust code

Local names in 40 languages
LanguageName in Excel
ArabicCONVERT
BulgarianCONVERT
CzechCONVERT
DanishCONVERT
GermanCONVERT
GreekCONVERT
English (Australia)CONVERT
English (United Kingdom)CONVERT
English (United States)CONVERT
SpanishCONVERT
EstonianCONVERT
FinnishMUUNNA
FrenchCONVERT
HebrewCONVERT
CroatianCONVERT
HungarianCONVERT
IndonesianCONVERT
ItalianCONVERTI
JapaneseCONVERT
KoreanCONVERT
LithuanianCONVERT
LatvianCONVERT
NorwegianCONVERT
DutchCONVERT
PolishCONVERT
Portuguese (Brazil)CONVERT
Portuguese (Portugal)CONVERT
RomanianCONVERT
RussianCONVERT
SlovakCONVERT
SlovenianCONVERT
Serbian (Latin)CONVERT
SwedishCONVERT
ThaiCONVERT
TurkishCONVERT
UkrainianCONVERT
VietnameseCONVERT
Chinese (Simplified)CONVERT
Chinese (Hong Kong)CONVERT
Chinese (Traditional)CONVERT

Names from Microsoft's support site.

What it does

CONVERT(number, from_unit, to_unit)

CONVERT(number, from_unit, to_unit) converts a measured quantity between supported units of the same dimension. Unit names are text codes, not the labels shown by cell formatting.

Try it

Input cells (optional)

Example: {"B2": 3, "B3": 4}. A1 holds the formula. Other cells need values before a formula can read them.

Enter a formula, then calculate.

Runs locally in your browser with OneCalc. Its answer may differ from Excel. Use English function names and commas between arguments.

=CONVERT(3,"ft","in") returns 36: each foot contributes twelve inches. =CONVERT(32,"F","C") returns zero; a temperature conversion needs an offset as well as a scale.

Prefix case changes the quantity. =CONVERT(1,"Mm","m") returns 1000000, whereas =CONVERT(1,"mm","m") returns 0.001. The first unit is a megametre and the second a millimetre.

Quirks

Unit codes and prefixes are case-sensitive. Microsoft documents #N/A for an unknown unit, a binary prefix not supported by its unit, or units from incompatible measurement groups; incorrect input types give #VALUE!. A mass-to-length conversion has no factor in this function.

The opened Microsoft unit list is broader than the current code table. It includes information units bit and byte and binary prefixes; the current helper implements a smaller linear-unit table and decimal prefixes. A preview #N/A for a documented unit can therefore be an implementation coverage gap. Do not infer an Excel rejection from that result alone.

Temperature offsets also prevent a single scale-only implementation. The current helper handles C, F and K through explicit pair formulas, and trims outer whitespace from unit strings before its case-sensitive lookup.

How to implement

Keep unit validation, linear arithmetic and temperature arithmetic separate.

For the current linear route, resolve each code to a measurement category, stored base factor and decimal-prefix exponent. Resolve a direct unit name before trying prefixes. Check that categories agree, then use the stored operation R:

product = R(number * from_factor)
core = R(product / to_factor)
result = R(core * stored_power_of_ten(from_prefix - to_prefix))

Prefix scaling is a separate final multiplication. Replacing the three steps by one precomputed ratio changes the rounding history. The source retains a disjoint 10,418-row check for its selected linear graph; that scope does not cover every documented unit or prove universal agreement.

For three feet to inches, the retained length factors are 3048000000 and 254000000. The product is 9144000000, the division gives 36, and prefix scaling multiplies by one. For metres to millimetres the base factors cancel, then the final prefix factor is 1000.

The current temperature route uses ordinary binary64 pair formulas. C to F is x*1.8+32; F to C is (x-32)/1.8; C to K adds 273.15. Do not replace division by the stored 1.8 with multiplication by a separately stored 5/9 when reproducing this code. An explicit reviewed unit table and the stated operation order are both needed; extending the table still requires its own Excel comparisons.

Rust code

Show the CalcFunc source of this function

Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.

CONVERT · 6 lines · calc-func/src/catalogue/engineering.rs on GitHub
72 convert "CONVERT" (3, 3) [V "number", V "from_unit", V "to_unit"] |s, a, sv| {
    let x = num(s, a, 0)?;
    let from = text(s, a, 1)?;
    let to = text(s, a, 2)?;
    out(s, k::misc_conversion_family::convert_kernel(x, &from, &to))
}
convert_direct_linear_unit · 127 lines · calc-func/src/ported/misc_conversion_family.rs on GitHub
fn convert_direct_linear_unit(unit: &str) -> Option<LinearUnit> {
    match unit {
        "m" => Some(LinearUnit {
            category: ConvertCategory::Length,
            factor_to_base: 10_000_000_000.0,
            prefix_exponent: 0,
        }),
        "in" => Some(LinearUnit {
            category: ConvertCategory::Length,
            factor_to_base: 254_000_000.0,
            prefix_exponent: 0,
        }),
        "ft" => Some(LinearUnit {
            category: ConvertCategory::Length,
            factor_to_base: 3_048_000_000.0,
            prefix_exponent: 0,
        }),
        "yd" => Some(LinearUnit {
            category: ConvertCategory::Length,
            factor_to_base: 9_144_000_000.0,
            prefix_exponent: 0,
        }),
        "mi" => Some(LinearUnit {
            category: ConvertCategory::Length,
            factor_to_base: 16_093_440_000_000.0,
            prefix_exponent: 0,
        }),
        "Nmi" => Some(LinearUnit {
            category: ConvertCategory::Length,
            factor_to_base: 18_520_000_000_000.0,
            prefix_exponent: 0,
        }),
        "g" => Some(LinearUnit {
            category: ConvertCategory::Mass,
            factor_to_base: 1.0,
            prefix_exponent: 0,
        }),
        "lbm" => Some(LinearUnit {
            category: ConvertCategory::Mass,
            factor_to_base: 453.59237,
            prefix_exponent: 0,
        }),
        "ozm" => Some(LinearUnit {
            category: ConvertCategory::Mass,
            factor_to_base: 28.349_523_125,
            prefix_exponent: 0,
        }),
        "sec" => Some(LinearUnit {
            category: ConvertCategory::Time,
            factor_to_base: 1.0,
            prefix_exponent: 0,
        }),
        "mn" => Some(LinearUnit {
            category: ConvertCategory::Time,
            factor_to_base: 60.0,
            prefix_exponent: 0,
        }),
        "hr" => Some(LinearUnit {
            category: ConvertCategory::Time,
            factor_to_base: 3600.0,
            prefix_exponent: 0,
        }),
        "day" => Some(LinearUnit {
            category: ConvertCategory::Time,
            factor_to_base: 86_400.0,
            prefix_exponent: 0,
        }),
        "Pa" => Some(LinearUnit {
            category: ConvertCategory::Pressure,
            factor_to_base: 1.0,
            prefix_exponent: 0,
        }),
        "atm" => Some(LinearUnit {
            category: ConvertCategory::Pressure,
            factor_to_base: 101_325.0,
            prefix_exponent: 0,
        }),
        "psi" => Some(LinearUnit {
            category: ConvertCategory::Pressure,
            // Reciprocal of the public units-per-pascal table entry
            // 1.4503773773020920E-04, independently rounded to binary64.
            factor_to_base: f64::from_bits(0x40ba_eec1_ddf7_0f99),
            prefix_exponent: 0,
        }),
        "l" => Some(LinearUnit {
            category: ConvertCategory::Volume,
            factor_to_base: 1.0,
            prefix_exponent: 0,
        }),
        "tsp" => Some(LinearUnit {
            category: ConvertCategory::Volume,
            factor_to_base: 0.004_928_921_593_75,
            prefix_exponent: 0,
        }),
        "tbs" => Some(LinearUnit {
            category: ConvertCategory::Volume,
            factor_to_base: 0.014_786_764_781_25,
            prefix_exponent: 0,
        }),
        "oz" => Some(LinearUnit {
            category: ConvertCategory::Volume,
            factor_to_base: 0.029_573_529_562_5,
            prefix_exponent: 0,
        }),
        "cup" => Some(LinearUnit {
            category: ConvertCategory::Volume,
            factor_to_base: 0.236_588_236_5,
            prefix_exponent: 0,
        }),
        "pt" => Some(LinearUnit {
            category: ConvertCategory::Volume,
            factor_to_base: 0.473_176_473,
            prefix_exponent: 0,
        }),
        "qt" => Some(LinearUnit {
            category: ConvertCategory::Volume,
            factor_to_base: 0.946_352_946,
            prefix_exponent: 0,
        }),
        "gal" => Some(LinearUnit {
            category: ConvertCategory::Volume,
            factor_to_base: 3.785_411_784,
            prefix_exponent: 0,
        }),
        _ => None,
    }
}
convert_prefix_exponent · 22 lines · calc-func/src/ported/misc_conversion_family.rs on GitHub
fn convert_prefix_exponent(prefix: &str) -> Option<i32> {
    match prefix {
        "Y" => Some(24),
        "Z" => Some(21),
        "E" => Some(18),
        "P" => Some(15),
        "T" => Some(12),
        "G" => Some(9),
        "M" => Some(6),
        "k" => Some(3),
        "h" => Some(2),
        "da" => Some(1),
        "d" => Some(-1),
        "c" => Some(-2),
        "m" => Some(-3),
        "u" => Some(-6),
        "n" => Some(-9),
        "p" => Some(-12),
        "f" => Some(-15),
        _ => None,
    }
}
convert_linear_unit · 13 lines · calc-func/src/ported/misc_conversion_family.rs on GitHub
fn convert_linear_unit(unit: &str) -> Option<LinearUnit> {
    if let Some(direct) = convert_direct_linear_unit(unit) {
        return Some(direct);
    }
    for base in ["sec", "Pa", "m", "g", "l"] {
        if let Some(prefix) = unit.strip_suffix(base) {
            let mut resolved = convert_direct_linear_unit(base)?;
            resolved.prefix_exponent = convert_prefix_exponent(prefix)?;
            return Some(resolved);
        }
    }
    None
}
convert_decimal_power10 · 4 lines · calc-func/src/ported/misc_conversion_family.rs on GitHub
fn convert_decimal_power10(exponent: i32) -> f64 {
    debug_assert!((-39..=39).contains(&exponent));
    CONVERT_DECIMAL_POW10[(exponent + 39) as usize]
}
convert_temperature · 12 lines · calc-func/src/ported/misc_conversion_family.rs on GitHub
fn convert_temperature(value: f64, from: &str, to: &str) -> Option<f64> {
    match (from, to) {
        (left, right) if left == right && matches!(left, "K" | "C" | "F") => Some(value),
        ("K", "C") => Some(value - 273.15),
        ("C", "K") => Some(value + 273.15),
        ("K", "F") => Some((value - 273.15) * 1.8 + 32.0),
        ("F", "K") => Some((value - 32.0) / 1.8 + 273.15),
        ("C", "F") => Some(value * 1.8 + 32.0),
        ("F", "C") => Some((value - 32.0) / 1.8),
        _ => None,
    }
}
convert_kernel · 26 lines · calc-func/src/ported/misc_conversion_family.rs on GitHub
pub fn convert_kernel(
    number: f64,
    from_unit: &str,
    to_unit: &str,
) -> Result<f64, WorksheetErrorCode> {
    if !number.is_finite() {
        return Err(WorksheetErrorCode::Value);
    }
    let from = from_unit.trim();
    let to = to_unit.trim();
    if let Some(converted) = convert_temperature(number, from, to) {
        return Ok(converted);
    }
    let from = convert_linear_unit(from).ok_or(WorksheetErrorCode::NA)?;
    let to = convert_linear_unit(to).ok_or(WorksheetErrorCode::NA)?;
    if from.category != to.category {
        return Err(WorksheetErrorCode::NA);
    }
    // Frozen W109 G4-05 graph, selected before and exact on the disjoint
    // 10,418-row publication check. Every arithmetic site is an x87 PC64 op
    // followed by a binary64 store; prefix scaling is a separate final site.
    let product = excel_x87_mul(number, from.factor_to_base);
    let core = excel_x87_div(product, to.factor_to_base);
    let prefix_delta = convert_decimal_power10(from.prefix_exponent - to.prefix_exponent);
    Ok(excel_x87_mul(core, prefix_delta))
}

Kernels shared with other functions

Argument and result plumbing

  • num catalogue/kit
  • out catalogue/kit
  • text catalogue/kit

No implementation has been published with a Handbook test suite for this function.

Version differences

The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.

Excel 16.0 buildPlatform and CPUCaptured inputs
20228Windows, 64-bit, CPU not recorded33,972

The record contains no same-input comparison between these environments. Reading different inputs on different builds does not establish either a version change or cross-build agreement.

Recorded environments and comparison details.

Excel 16.0 build 20228

Windows, 64-bit, CPU not recorded

33,972 captured inputs are indexed for this environment. Capture dates: 2026-08-09 to 2026-08-09. This is a reading count, not a comparison with another build.

Alternatives

EUROCONVERT handles its specified currency table. Direct multiplication is clear for a single known factor, but does not validate units or handle offsets.

Named variants

No named variants are recorded yet.

Suggest a correction or contribute an implementation · For agents