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

Comparison of num::rational::Ratio is incorrect with overflow #7

Closed
rust-highfive opened this issue Sep 28, 2014 · 0 comments
Closed

Comments

@rust-highfive
Copy link

Issue by huonw
Monday Aug 12, 2013 at 09:23 GMT

For earlier discussion, see rust-lang/rust#8466

This issue was labelled with: A-libs in the Rust repository


extern crate num;
use num::rational::Ratio;

fn main() {
    let big = Ratio::new(128u8, 1);
    let small = big.recip();
    assert!(big > small);
}

fails the assertion. (It's comparing 128 with 1/128.)

This, or something similar, happens for any type that can overflow (I guess one could argue that fixed size types are "unsupported" for rational numbers, and so this overflow leads to unspecified behaviour).

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