# Properties of Range

**URL:** <https://discourse.julialang.org/t/properties-of-range/8298>\
**Category:** General Usage\
**Created:** [January 11, 2018, 10:37pm UTC](https://discourse.julialang.org/t/properties-of-range/8298 "2018-01-11T22:37:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![goldfita](https://avatars.discourse-cdn.com/v4/letter/g/4491bb/32.png) [@goldfita](https://discourse.julialang.org/u/goldfita)\
**Post date:** [January 11, 2018, 10:37pm UTC](https://discourse.julialang.org/t/properties-of-range/8298/1 "2018-01-11T22:37:06Z")

</div>

Should I expect that the length of a range is preserved under arithmetic operations on the range? I ran into a bug where simply changing the sign in front of a range in an expression caused a dimension mismatch error. For example:

```julia
julia> collect((22:-1:7)-0.0030026930763747783)
15-element Array{Float64,1}:
 21.997
 20.997
 19.997
 18.997
 17.997
 16.997
 15.997
 14.997
 13.997
 12.997
 11.997
 10.997
  9.997
  8.997
  7.997

julia> collect((22:-1:7))-0.0030026930763747783
16-element Array{Float64,1}:
 21.997
 20.997
 19.997
 18.997
 17.997
 16.997
 15.997
 14.997
 13.997
 12.997
 11.997
 10.997
  9.997
  8.997
  7.997
  6.997

```

After some experimentation, I discovered, at least in this example, if the range is floating point, I get the expected behavior. But then you get the weird property that the following are not the same. Also, I don’t know if the length preservation holds in general.

```julia
# Should these be the same?
((22:-1:7)*1.0)-0.0030026930763747783
(22:-1:7)-0.0030026930763747783

```

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [January 11, 2018, 11:13pm UTC](https://discourse.julialang.org/t/properties-of-range/8298/2 "2018-01-11T23:13:20Z")

</div>

This is definitely a bug, I’ve opened an issue: [https://github.com/JuliaLang/julia/issues/25521](https://github.com/JuliaLang/julia/issues/25521)
