# Potential solution to the overflow problem; 64-bit considered harmful, 32- or 21-bit better

**URL:** https://discourse.julialang.org/t/potential-solution-to-the-overflow-problem-64-bit-considered-harmful-32-or-21-bit-better/69918
**Category:** General Usage
**Tags:** integer-overflow
**Created:** [October 17, 2021, 12:29am UTC](https://discourse.julialang.org/t/potential-solution-to-the-overflow-problem-64-bit-considered-harmful-32-or-21-bit-better/69918 "2021-10-17T00:29:46Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)
#### Post date: [October 17, 2021, 5:32pm UTC](https://discourse.julialang.org/t/potential-solution-to-the-overflow-problem-64-bit-considered-harmful-32-or-21-bit-better/69918/6 "2021-10-17T17:32:25Z")

</div>

> [@cjdoris](#):
>
> if the user opted to use `Int` then the user must be sure the result cannot overflow

You can’t rely on (and users don’t really opt in to `Int` or `Int64` so much, I think they use out of habit, as that’s the default, which is my main message):

```julia
julia> typemax(Int)
9223372036854775807

```

On 32-bit it’s “only” 2147483647, but yes, that’s already very generous (while more likely to overflow, e.g. for intermediate calculations like the distance calculation I showed, ~~would for x or y as high as 46341 or 32-bit~~ ), why I suggested `Int21` as a happy medium with 1048576 as a maximum, _for input data_, for output (and all intermediate numbers), the sky is the limit. If I learned anything from Steve Jobs/macOS, then it’s sensible defaults are good. I do not rule out smaller types used, just not as defaults, if you need to chose one.

EDIT: I assumed `^` would give you Int32 on 32-bit, but actually Int32 input for it or `*` widens to Int64 output (but Int8, Int16 and Int64 do not widen), at least on 64-bit, so my idea is already partially implemented, while it can still overflow for Int64 input, and most likely will for Int16 or smaller.

---

_[View the full topic](https://discourse.julialang.org/t/potential-solution-to-the-overflow-problem-64-bit-considered-harmful-32-or-21-bit-better/69918)._
