# Start, step, length for \`range\`

**URL:** <https://discourse.julialang.org/t/start-step-length-for-range/56465>\
**Category:** Internals & Design\
**Created:** [March 4, 2021, 8:48am UTC](https://discourse.julialang.org/t/start-step-length-for-range/56465 "2021-03-04T08:48:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [March 4, 2021, 8:48am UTC](https://discourse.julialang.org/t/start-step-length-for-range/56465/1 "2021-03-04T08:48:28Z")

</div>

I am getting an error when trying to create a range with a start, step, length:

```julia
julia> range(start=0, step=fs, length=2^10)
ERROR: MethodError: no method matching range(; start=0, step=0.01, length=1024)

```

Is there any good reason why this is not a method? It is useful in my context, which is when I know a sampling-frequency, and want to have a length that is a power of 2 for FFT-purposes.

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [March 4, 2021, 8:58am UTC](https://discourse.julialang.org/t/start-step-length-for-range/56465/2 "2021-03-04T08:58:50Z")

</div>

I quickly realized that I can create the wanted range by `0:fs:fs*(2^10-1)`, but it would be nice to have the more explicit method using `range()` available - it is useful, as demonstrated by the fact that I initially forgot to include the -1 necessary to get the desired length.

---

<div class="post-metadata">

**Author:** ![helgee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/helgee/32/2022_2.png) [@helgee](https://discourse.julialang.org/u/helgee)\
**Post date:** [March 4, 2021, 9:11am UTC](https://discourse.julialang.org/t/start-step-length-for-range/56465/3 "2021-03-04T09:11:06Z")

</div>

`start` is a positional argument, so this works

```julia
julia> range(0, step=0.01, length=2^10)
0.0:0.01:10.23

```

There has been this issue recently which discussed the design of the `range` API in detail:

[https://github.com/JuliaLang/julia/issues/38750](https://github.com/JuliaLang/julia/issues/38750)

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [March 4, 2021, 9:11am UTC](https://discourse.julialang.org/t/start-step-length-for-range/56465/4 "2021-03-04T09:11:52Z")

</div>

It was fixed in 1.7. You just need to wait when it will be announced as release candidate. Till that time you should use your workaround or use start as a positional argument as it was said in previous comment.

```julia
julia> range(start=0, step=0.01, length=2^10)
0.0:0.01:10.23

julia> versioninfo()
Julia Version 1.7.0-DEV.538

```

---

<div class="post-metadata">

**Author:** ![TheLateKronos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thelatekronos/32/12824_2.png) [@TheLateKronos](https://discourse.julialang.org/u/TheLateKronos)\
**Post date:** [March 4, 2021, 9:32am UTC](https://discourse.julialang.org/t/start-step-length-for-range/56465/5 "2021-03-04T09:32:20Z")

</div>

Amazing, good to hear.
