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

make rational arithmetic use checked ops #8672

Merged
merged 1 commit into from
Oct 23, 2014

Conversation

simonbyrne
Copy link
Contributor

This makes all rational arithmetic operations use checked integer operations to avoid overflow. Along with #8463, this should solve #2960.

@StefanKarpinski
Copy link
Sponsor Member

This is a big improvement. How's the performance? I'm guessing it's not so bad considering all the gcd operations that get done all the time anyway.

@simonbyrne
Copy link
Contributor Author

It seems to incur a slight penalty of about 5-10% vs master, but still 30% faster than 0.3 (I assume due to #8410).

@StefanKarpinski
Copy link
Sponsor Member

Nice

@simonbyrne
Copy link
Contributor Author

I think if we really wanted to tweak performance of rationals, one way would be to have an option to not perform the gcd in the constructor when it isn't required, e.g. for Rational(::Int) or after a multiplication or division.

@StefanKarpinski
Copy link
Sponsor Member

That seems like it would be an improvement. I guess that would require having a way of constructing Rational values, bypassing the gcd. Maybe a//b could do the gcd while Rational(a,b) just constructs.

nolta added a commit that referenced this pull request Oct 23, 2014
make rational arithmetic use checked ops
@nolta nolta merged commit 0fdc31c into JuliaLang:master Oct 23, 2014
@simonbyrne simonbyrne deleted the check-rational branch March 10, 2015 12:01
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

Successfully merging this pull request may close these issues.

3 participants