# How to throw an error on value overflow?

**URL:** <https://discourse.julialang.org/t/how-to-throw-an-error-on-value-overflow/3408>\
**Category:** General Usage\
**Tags:** integer-overflow\
**Created:** [April 27, 2017, 7:00pm UTC](https://discourse.julialang.org/t/how-to-throw-an-error-on-value-overflow/3408 "2017-04-27T19:00:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [April 27, 2017, 7:00pm UTC](https://discourse.julialang.org/t/how-to-throw-an-error-on-value-overflow/3408/1 "2017-04-27T19:00:09Z")

</div>

For example, in `Int64`:

`10^21` returns `3875820019684212736`

How do you turn off rollover and just throw an error instead?

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [April 27, 2017, 9:20pm UTC](https://discourse.julialang.org/t/how-to-throw-an-error-on-value-overflow/3408/2 "2017-04-27T21:20:11Z")

</div>

You can’t, but upon consideration I feel like it might be worth it to do integer overflow checking for ^. It’s relatively isolated, and it’s the most common place where people encounter this. I’ll submit a PR to this effect and see what people think.

---

<div class="post-metadata">

**Author:** ![djsegal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/djsegal/32/13752_2.png) [@djsegal](https://discourse.julialang.org/u/djsegal)\
**Post date:** [May 7, 2017, 9:38pm UTC](https://discourse.julialang.org/t/how-to-throw-an-error-on-value-overflow/3408/3 "2017-05-07T21:38:54Z")

</div>

PR can be seen here:

- [https://github.com/JuliaLang/julia/pull/21600](https://github.com/JuliaLang/julia/pull/21600)
