Skip to content

Conversion factor doc inconsistency #424

@NiklasVousten

Description

@NiklasVousten

The documentation stated that Conversion is handled like this: (value * coefficient()) + constant()

But using this code snipped for a manual conversion like Fahrenheit to Kelvin this breaks:

fn test() {
    let f: f32 = 2.0;
    let k = convert::<uom::si::thermodynamic_temperature::degree_fahrenheit>(f);
    println!("{k:?}");
}

fn convert<N>(value: f32) -> f32
where
    N: uom::Conversion<f32, T = f32>,
{
    (value * N::coefficient()) + N::constant(uom::ConstantOp::Add)
}

The result is 460.78113, but 2 degrees Fahrenheit is 256.483

Rewriting the equation to (value + constant()) * coefficient() results in 256.48337

So there is an inconsistency between code and documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions