-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
overflow in Rational arithmetic #2960
Comments
Looks like we've made some progress on this: julia> 3//2 > typemax(Int)
false |
Given how easy it is to overflow Rational, maybe it would be a good idea to make rations use checked arithmetic? |
Rationals need to be fixed 0.4 (what this? they even had their own tag), so I've picked a random issue and tagged it 0.4. And yes, I'm volunteering myself if nobody else beats me too it. |
Note that comparisons are broken even without overflow: julia> a = 1//3
1//3
julia> b = 1/3
0.3333333333333333
julia> BigFloat(a) > BigFloat(b)
true
julia> a > b
false
julia> a < b
false
julia> a == b
false
julia> a >= b
true
julia> a <= b
true However I don't know of any great way to fix this. One idea would be to sequentially compare each element of the continued fraction expansion of each number (obtained via the Euclidean algorithm). |
These should now all be sorted: if not, please reopen. |
Rational - Int comparisons are susceptible to overflow:
This is due to multiplying the integer argument by the rational's denominator.
Other operations that use
*
this way are similarly afflicted:The text was updated successfully, but these errors were encountered: