# Why does the type of an index default to Int?

**URL:** <https://discourse.julialang.org/t/why-does-the-type-of-an-index-default-to-int/5802>\
**Category:** Internals & Design\
**Tags:** question, proposal\
**Created:** [September 9, 2017, 6:42pm UTC](https://discourse.julialang.org/t/why-does-the-type-of-an-index-default-to-int/5802 "2017-09-09T18:42:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [September 9, 2017, 6:42pm UTC](https://discourse.julialang.org/t/why-does-the-type-of-an-index-default-to-int/5802/1 "2017-09-09T18:42:46Z")

</div>

I’m wondering why functions like `find` return `Int` instead of say `UInt`. Indexes, as such, cannot be negative, so they should be unsigned, and the scope of `UInt`is much larger than an `Int` (not that we would need an array of length 1.8446744073709552e19). Would it make sense to have some native index type instead of the default `Int`?

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [September 9, 2017, 8:09pm UTC](https://discourse.julialang.org/t/why-does-the-type-of-an-index-default-to-int/5802/2 "2017-09-09T20:09:23Z")

</div>

I guess that wouldn’t work for OffsetArrays.

---

<div class="post-metadata">

**Author:** ![tobias.knopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobias.knopp/32/7551_2.png) [@tobias.knopp](https://discourse.julialang.org/u/tobias.knopp)\
**Post date:** [September 9, 2017, 8:51pm UTC](https://discourse.julialang.org/t/why-does-the-type-of-an-index-default-to-int/5802/3 "2017-09-09T20:51:32Z")

</div>

using unsigned ints for indexing would we problematic in index calculations. There are many discussions out there on the Web (for C/C++)

The greater range is (by the way) just a factor of two. This will certainly not be an issue in practice.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [September 9, 2017, 9:18pm UTC](https://discourse.julialang.org/t/why-does-the-type-of-an-index-default-to-int/5802/4 "2017-09-09T21:18:06Z")

</div>

Thanks! Good to know this has been thought of before.

I have a feeling that there should be a Venn diagram for “Why and how things are done in C/Matlab/Python” and “Why and how things are done in Julia”. The overlap between the two circles was understandably large at the beginning and diminished some with Julia’s development. I can’t help wonder if radical thoughts, such as a special UInt-y index type, are becoming more and more advantageous, separating those two circles even more apart…

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [September 10, 2017, 9:57am UTC](https://discourse.julialang.org/t/why-does-the-type-of-an-index-default-to-int/5802/5 "2017-09-10T09:57:38Z")

</div>

These kind of issues have been covered at length by core developers in old posts either on Discourse or on the former Google Groups. It would indeed be nice to collect them into a FAQ so they are easier to find.
