-
-
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
binomial no longer uses Float64 internally. #6163
Conversation
rr += 1 | ||
nn += 1 | ||
end | ||
sgn*iround(T,x) | ||
x < 0 && throw(OverflowError()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure x
will always be negative if there's an overflow? That doesn't seem plausible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is sufficient but not necessary. Maybe this should be in the inner loop? x
always starts positive and is multiplied and divided by positive numbers, so the only way to make it negative is due to overflow. I don't think it is possible in the inner loop to overflow and remain positive because the factors aren't that large.
I still don't think
|
Using your code above I still get Forcing temp = div(widemul(x,nn), rr)
x::T = temp
x != temp && throw(OverflowError()) renders the |
The code seems ok, though I don't think you need/use |
Replaces the old accumulation step, using x=*(nn::Float64, rr::Float64) with x::T=xt=div(widemul(x,nn), rr). Also tests for integer overflow. Fix #6154.
Thanks for catching that. |
binomial no longer uses Float64 internally.
Replaces the old accumulation step, using
x=*(nn::Float64, rr::Float64)
,with
x::T=div(widemul(x,nn), rr)
as suggested by @JeffBezanson.Previously,
binomial(54,23)
computed the wrong answer. The new thresholds are:Int32
OverflowError()
)Int64
OverflowError()
)Int128
OverflowError()
)Fix #6154.