# Array index math to be Int64

**URL:** <https://discourse.julialang.org/t/array-index-math-to-be-int64/9640>\
**Category:** New to Julia\
**Created:** [March 11, 2018, 3:33am UTC](https://discourse.julialang.org/t/array-index-math-to-be-int64/9640 "2018-03-11T03:33:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![J-Light](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@J-Light](https://discourse.julialang.org/u/J-Light)\
**Post date:** [March 11, 2018, 3:33am UTC](https://discourse.julialang.org/t/array-index-math-to-be-int64/9640/1 "2018-03-11T03:33:35Z")

</div>

Hi  
I am trying to fill in an array such that information in in the middle. However, I find that I need to cast the Rational (or even Real for that matter) into an Int64 before I can actually use it to index into the array.

Any way I can do this better / avoid the ugly casts.

```julia
bump = (2/3 - 1/3 * cos.(ω * tInput))
inputSignal = zeros(t)
startIdx = Int64(length(t)//2 - length(tInput)//2)
inputSignal[startIdx:startIdx + length(tInput) - 1] = bump

```

Cheers!  
J

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [March 11, 2018, 5:09am UTC](https://discourse.julialang.org/t/array-index-math-to-be-int64/9640/2 "2018-03-11T05:09:45Z")

</div>

```julia
julia> div(13,2),typeof(div(13,2))
(6, Int64)
# same thing, but prettier:
julia> 13÷2,typeof(13÷2)
(6, Int64)

```

If you already looked in the manual but didn’t see this, please suggest where elaboration would seem helpful (or better, file an issue/PR).

One can also use `round` or bit-shifts, but `div` seems cleanest here.
