# Rand chokes on UInt64

**URL:** <https://discourse.julialang.org/t/rand-chokes-on-uint64/7790>\
**Category:** Internals & Design\
**Created:** [December 15, 2017, 2:47pm UTC](https://discourse.julialang.org/t/rand-chokes-on-uint64/7790 "2017-12-15T14:47:11Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [December 15, 2017, 2:55pm UTC](https://discourse.julialang.org/t/rand-chokes-on-uint64/7790/2 "2017-12-15T14:55:41Z")

</div>

Try

```julia
rand(Base.Random.GLOBAL_RNG, 0:10, 4)

```

Even though indexes are “logically” unsigned for plain vanilla arrays, the convention in Julia is to use `Int`. This prevents unpleasant surprises when doing arithmetic (eg consider subtraction which would result in a negative value, etc).

Slightly related, see the discussion there:

> [@Fill function requiring same Int type in the tuple](https://discourse.julialang.org/t/fill-function-requiring-same-int-type-in-the-tuple/7660):
>
> I would have thought that the fill() function is smarter. Now I have to cast to the widest type before calling it… Any thoughts? Am I too picky? julia\> fill(0, (Int64(10), Int32(8))) ERROR: MethodError: no method matching fill(::Int64, ::Tuple{Int64,Int32}) Closest candidates are: fill(::Any, ::Tuple{Vararg{Int64,N}} where N) at array.jl:253 fill(::Any, ::Integer...) at array.jl:254 julia\> fill(0, (Int64(10), Int64(8))) 10×8 Array{Int64,2}: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0…

---

_[View the full topic](https://discourse.julialang.org/t/rand-chokes-on-uint64/7790)._
