# Why Combinatorics package doesn't warn of overflow?

**URL:** <https://discourse.julialang.org/t/why-combinatorics-package-doesnt-warn-of-overflow/47136>\
**Category:** General Usage\
**Created:** [September 23, 2020, 2:00pm UTC](https://discourse.julialang.org/t/why-combinatorics-package-doesnt-warn-of-overflow/47136 "2020-09-23T14:00:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [September 23, 2020, 2:00pm UTC](https://discourse.julialang.org/t/why-combinatorics-package-doesnt-warn-of-overflow/47136/1 "2020-09-23T14:00:38Z")

</div>

This is dangerous, as the following code doesn’t emit any warning, just give very different results (I assume due to overflowing ???)

```julia
using Combinatorics

# 4 players get exactly one ace each:
sol1 = 4 * 3 *2 * multinomial(12,12,12,12)/multinomial(13,13,13,13) # 0 .838
sol2 = 4 * 3 *2 * (multinomial(12,12,12,12)/multinomial(13,13,13,13)) # -9.47
sol3 = 4 * 3 *2 * (multinomial(BigInt(12),12,12,12)/multinomial(BigInt(13),13,13,13)) # 0.105
sol4 = 4 * 3 *2 * multinomial(BigInt(12),12,12,12)/multinomial(BigInt(13),13,13,13) # 0.105
sol5 = 4 * 3 *2 * (multinomial(BigInt(12),BigInt(12),BigInt(12),BigInt(12))/multinomial(BigInt(13),BigInt(13),BigInt(13),BigInt(13))) # 0.105

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [September 23, 2020, 2:42pm UTC](https://discourse.julialang.org/t/why-combinatorics-package-doesnt-warn-of-overflow/47136/2 "2020-09-23T14:42:26Z")

</div>

[https://github.com/JuliaMath/Combinatorics.jl/blob/1ab5eb1e0014af0ff06288d5530e1d5e649bef96/src/factorials.jl#L100](https://github.com/JuliaMath/Combinatorics.jl/blob/1ab5eb1e0014af0ff06288d5530e1d5e649bef96/src/factorials.jl#L100)

yep, not making it “big” by default, you can file an issue maybe

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [September 23, 2020, 2:52pm UTC](https://discourse.julialang.org/t/why-combinatorics-package-doesnt-warn-of-overflow/47136/3 "2020-09-23T14:52:38Z")

</div>

yep… interesting, I thought the overflow error was a “safety net” of the language, while it is instead a check specifically implemented in the `binomial` function… so, if the individual `binomial` computation in `multinomial` doesn’t overflow, neither does `multinomial`, e.g.

`multinomial(150, 150, 150, 150)` → error overflow  
`multinomial(15, 15, 15, 15)` → no error reported

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [September 23, 2020, 2:54pm UTC](https://discourse.julialang.org/t/why-combinatorics-package-doesnt-warn-of-overflow/47136/4 "2020-09-23T14:54:20Z")

</div>

right; Julia by default does not check overflow, for performance reason, similar to C/C++. But pkgs like Combinatorics I’d imagine have good reason to either make `big` by default(see for example `derangement` function), or check overflow.
