-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
mod1, fld1, rem1 broken #5570
Comments
This is indeed broken. mod1(x,y) doesn't work at all for unsigned x,y when x>y. Moreover fld1(x,y) gives rather less useful results for signed x<=0 and incorrect results for unsigned x=0. julia> [rem1(k,5) for k=-10:10]'
1x21 Array{Int64,2}:
0 1 -3 -2 -1 0 1 -3 -2 -1 0 1 2 3 4 5 1 2 3 4 5
julia> rem1(uint(0),uint(11))
0x0000000000000005 |
The definition for mod1{T<:Real}(x::T, y::T) = y-mod(y-x,y) For moderately large |
When I wrote fld1 above I actually meant rem1, as in the examples, but it's valid for fld1 too. Those are really only designed to be used for integer x > 0 and y > 0, in the context of 1-based indexing. The simplest solution for rem1 may be to document that it's only intended for x > 0 and otherwise refer to mod1. Or unexport it; the difference between rem and mod is how they behave for negative arguments and it's not clear that this distinction is interesting or even relevant for rem1/mod1. As for the mod1 problem at the core of this issue there seems to be a very simple solution. It was broken by this commit with the comment
When I test it now I see no measurable speed difference, so just revert that change. |
We should at least add the old method definition for |
Btw, @StefanKarpinski did you see this? |
This should perhaps get a bug tag. |
Note: |
Great |
It is like this since 0.1.2.
The text was updated successfully, but these errors were encountered: