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

Fix mod1 #9643

Merged
merged 1 commit into from
Jan 18, 2015
Merged

Fix mod1 #9643

merged 1 commit into from
Jan 18, 2015

Conversation

jiahao
Copy link
Member

@jiahao jiahao commented Jan 6, 2015

Restore old implementation of mod1 that was overwritten in 3842422

Adds test of mod1 behavior from #5570

Note: #5570 is not fixed for fld1, rem1. The documentation bug of #8108 is not fixed.

cc: @GunnarFarneback @StefanKarpinski @mschauer

@@ -131,7 +131,7 @@ const % = rem
const ÷ = div

# mod returns in [0,y) whereas mod1 returns in (0,y]
mod1{T<:Real}(x::T, y::T) = y-mod(y-x,y)
mod1{T<:Real}(x::T, y::T) = (m=mod(x,y); m==0 ? y : m)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use ifelse here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, changed.

@ivarne
Copy link
Member

ivarne commented Jan 12, 2015

Bump! (needs a rebase because git is don't know what order to append new tests at the bottom of test/numbers.jl)

@mschauer
Copy link
Contributor

And not really the slow old implementation, but equally fast (due to the use of ifelse, I suppose).

Restore old implementation of mod1 that was overwritten in
3842422

Adds test of mod1 behavior from #5570

Note: #5570 is not fixed for fld1, rem1. The documentation bug of #8108
is not fixed.
jiahao added a commit that referenced this pull request Jan 18, 2015
@jiahao jiahao merged commit faa0466 into master Jan 18, 2015
@jiahao jiahao deleted the cjh/fix-5570 branch January 18, 2015 02:37
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.

4 participants