iliekturtles / uom

Units of measurement -- type-safe zero-cost dimensional analysis
Apache License 2.0
989 stars 89 forks source link

Unit conversion problem using BigRational #461

Open osamuta opened 5 months ago

osamuta commented 5 months ago

Hello.

I encountered a conversion problem second to millisecond using BigRational implementation. It appears that the problem may be related to the floating-point precision of the conversion factor.

Is this bug?

use num::{BigRational, One};
use uom::si::bigrational::*;
use uom::si::time::{millisecond, second};

fn main() {
    let t = Time::new::<second>(BigRational::one());
    eprintln!("{}", t.get::<millisecond>()); //Expected: 1000/1, Actual: 1152921504606846976/1152921504606847
}