-
Notifications
You must be signed in to change notification settings - Fork 53
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
Figure out a good convention for normalizing rational numbers #8
Comments
I think normalizing after each operation is the way to go here. Also, is this a good definition of normalized?
This makes sense to me - you will generally get worse performance (bignums) or a higher chance of overflow (constant size numbers) from not reducing rationals during operations. What do we think is the use case for raw manipulation, and what might these raw manipulation methods look like? |
Yes, normalized |
Thumbing through the code, it indeed appears as if every ratio is reduced after an operation on it. If this is the desired behavior, and I think it should be, we should probably add tests specifically for it, and document somewhere that that's how this crate works. |
Now that #42 is merged, for any operation, if input In this change I'm suggesting, we would make Preliminary research: The most popular dependent crate (image-rs) uses Ratios sparingly. It only constructs them using |
From @rust-highfive on September 28, 2014 22:43
Issue by thestinger
Friday Apr 05, 2013 at 08:48 GMT
For earlier discussion, see rust-lang/rust#5738
This issue was labelled with: A-libs in the Rust repository
The gmp
Mpq
type does does it after each operation, and then exposes a raw interface for doing a few operations without normalizing. It only guarantees that operations are valid when the type is normalized. This leads to the most predictable performance with big integers, and avoids avoidable overflows for fixed size ones.This would probably involve making the fields
priv
and using scary names for raw manipulation methods.Copied from original issue: rust-num/num#6
The text was updated successfully, but these errors were encountered: