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

Integers not correctly handled in num::rational #16386

Closed
tbu- opened this issue Aug 9, 2014 · 3 comments
Closed

Integers not correctly handled in num::rational #16386

tbu- opened this issue Aug 9, 2014 · 3 comments

Comments

@tbu-
Copy link
Contributor

tbu- commented Aug 9, 2014

  • Possible-machine integers are treated as mathematical integers: Ratio::reduce, where the unary minus operator on a negative number is assumed to yield a positive number.
  • self.denom is compared to Zero::zero instead of calling is_zero().
  • Ratio::recip might return a fractions with a denominator of 0.

There are also some issues regarding overflows, it seems the module just hopes that they won't happen at all – except for wrong results, this could also raise a fail!()ure, when e.g. 1/sqrt(max_int) is multiplied with itself, yielding 1/0.

This might mean that Rust needs some general guideline on how to treat integer overflow.

@huonw
Copy link
Member

huonw commented Aug 9, 2014

#8466 is related.

@rust-highfive
Copy link
Collaborator

This issue has been moved to the RFCs repo: rust-lang/rfcs#337

@rust-highfive
Copy link
Collaborator

This issue has been moved to the RFCs repo: rust-num/num#11

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

4 participants