This can be seen by applying float to the interval:
julia> 1:10 1:10 julia> float(1:10) 1.0:1.0:10.0
and this promotion is required before adding to Float64 4/1 ( 4.0 ).
Similarly, when adding an integer to a float, julia βpushesβ the integer to a float before adding / subtracting:
julia> 1 + 2.0 3.0 julia> @which 1 + 2.0 +(x::Number, y::Number) at promotion.jl:172
see promotion rules :
+(x::Number, y::Number) = +(promote(x,y)...)
You can @which follow function calls to the end to understand what is going on (completely the following ):
julia> @which +(1:10, 2.0) +(A::AbstractArray{T,N}, x::Number) at arraymath.jl julia> @which .+(1:10, 2.0) .+(r::Range{T}, x::Real) at range.jl julia> @which .+(2.0, 1:10) .+(x::Real, r::UnitRange{T<:Real}) at range.jl # which is defined as .+(x::Real, r::UnitRange) = range(x + r.start, length(r))
and therefore promotion is the addition of Int64 and Float64.
Note in the main mode the interval display is somewhat less confusing / ambiguous:
julia> float(1:10) 10-element FloatRange{Float64}: 1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0 julia> 1:10 10-element UnitRange{Int64}: 1,2,3,4,5,6,7,8,9,10