Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit conversion problem using BigRational #461

Open
osamuta opened this issue Feb 9, 2024 · 0 comments
Open

Unit conversion problem using BigRational #461

osamuta opened this issue Feb 9, 2024 · 0 comments

Comments

@osamuta
Copy link

osamuta commented Feb 9, 2024

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
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant