iliekturtles / uom

Units of measurement -- type-safe zero-cost dimensional analysis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unit conversion problem using BigRational

osamuta opened this issue · comments

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
}