@@ -408,7 +408,7 @@ function floatrange(a::AbstractFloat, st::AbstractFloat, len::Real, divisor::Abs
408
408
steprangelen_hp (T, (a,divisor), (st,divisor), nbitslen (T, len, 1 ), len, oneunit (len))
409
409
end
410
410
411
- function (:)(start:: T , step:: T , stop:: T ) where T<: Union{Float16,Float32,Float64}
411
+ function (:)(start:: T , step:: T , stop:: T ) where T<: IEEEFloat
412
412
step == 0 && throw (ArgumentError (" range step cannot be zero" ))
413
413
# see if the inputs have exact rational approximations (and if so,
414
414
# perform all computations in terms of the rationals)
453
453
step (r:: StepRangeLen{T,TwicePrecision{T},TwicePrecision{T}} ) where {T<: AbstractFloat } = T (r. step)
454
454
step (r:: StepRangeLen{T,TwicePrecision{T},TwicePrecision{T}} ) where {T} = T (r. step)
455
455
456
- function range_start_step_length (a:: T , st:: T , len:: Integer ) where T<: Union{Float16,Float32,Float64}
456
+ range_start_step_length (a, st:: IEEEFloat , len:: Integer ) =
457
+ range_start_step_length (oftype (st, a), st, len)
458
+
459
+ function range_start_step_length (a:: T , st:: T , len:: Integer ) where T<: IEEEFloat
457
460
len = len + 0 # promote with Int
458
461
start_n, start_d = rat (a)
459
462
step_n, step_d = rat (st)
@@ -471,6 +474,11 @@ function range_start_step_length(a::T, st::T, len::Integer) where T<:Union{Float
471
474
steprangelen_hp (T, a, st, 0 , len, 1 )
472
475
end
473
476
477
+ function range_step_stop_length (step:: IEEEFloat , stop, len:: Integer )
478
+ r = range_start_step_length (stop, negate (step), len)
479
+ reverse (r)
480
+ end
481
+
474
482
# This assumes that r.step has already been split so that (0:len-1)*r.step.hi is exact
475
483
function unsafe_getindex (r:: StepRangeLen{T,<:TwicePrecision,<:TwicePrecision} , i:: Integer ) where T
476
484
# Very similar to _getindex_hiprec, but optimized to avoid a 2nd call to add12
0 commit comments