# StepRange and arithmetics

**URL:** <https://discourse.julialang.org/t/steprange-and-arithmetics/12667>\
**Category:** New to Julia\
**Created:** [July 26, 2018, 2:00pm UTC](https://discourse.julialang.org/t/steprange-and-arithmetics/12667 "2018-07-26T14:00:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [July 26, 2018, 2:00pm UTC](https://discourse.julialang.org/t/steprange-and-arithmetics/12667/1 "2018-07-26T14:00:11Z")

</div>

in 0.7-beta2, StepRange + Number “rounds” differently than Vector + Number. Should I be surprised?

Example:

```julia
x = -10.0:0.1:5.0
z1 = x[1] + 10
z2 = x[1:2] .+ 10
z3 = collect(x[1:2]) .+ 10
println(z1," ",z2[1]," ",z3[1])

```

gives

```julia
0.0 5.127595883936577e-30 0.0

```

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [July 26, 2018, 2:25pm UTC](https://discourse.julialang.org/t/steprange-and-arithmetics/12667/2 "2018-07-26T14:25:37Z")

</div>

Try looking at the types of the resulting values.

---

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [July 26, 2018, 2:38pm UTC](https://discourse.julialang.org/t/steprange-and-arithmetics/12667/3 "2018-07-26T14:38:49Z")

</div>

OK, they are clearly Float64, StepRangeLen{Float64,…}, and Array{Float64} respectively.

I expected them to behave the same when used in simple computations (here plus 10), but that does not seem to be the case. Where can I read up on this?

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [July 26, 2018, 2:48pm UTC](https://discourse.julialang.org/t/steprange-and-arithmetics/12667/4 "2018-07-26T14:48:23Z")

</div>

Ranges use higher precision internally. This was discussed in a few pull requests but I’m not at my computer right now.
