Skip to content

Commit

Permalink
binomial should throw OverflowError instead of InexactError (#25498)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne authored Jan 11, 2018
1 parent a3496f2 commit 4440b0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/intfuncs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ function binomial(n::T, k::T) where T<:Integer
rr = 2
while rr <= k
xt = div(widemul(x, nn), rr)
x = xt
x = xt % T
x == xt || throw(OverflowError("binomial($n0, $k0) overflows"))
rr += 1
nn += 1
Expand Down
2 changes: 1 addition & 1 deletion test/combinatorics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@test binomial(Int32(34), Int32(15)) == binomial(BigInt(34), BigInt(15)) == 1855967520
@test binomial(Int64(67), Int64(29)) == binomial(BigInt(67), BigInt(29)) == 7886597962249166160
@test binomial(Int128(131), Int128(62)) == binomial(BigInt(131), BigInt(62)) == 157311720980559117816198361912717812000
@test_throws InexactError binomial(Int64(67), Int64(30))
@test_throws OverflowError binomial(Int64(67), Int64(30))
end

@testset "permutations" begin
Expand Down

2 comments on commit 4440b0f

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.