From ebdfbce840e37eb0f66f8f323d6bd68fbfd47eef Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sun, 17 Feb 2013 16:50:04 -0500 Subject: [PATCH] another float range fix (#2333). thanks to @stevengj --- base/range.jl | 4 +++- test/corelib.jl | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/base/range.jl b/base/range.jl index 398a794c41caf..3018847d5d570 100644 --- a/base/range.jl +++ b/base/range.jl @@ -71,8 +71,10 @@ function colon{T<:Real}(start::T, step::T, stop::T) if abs(n-nf) < eps(n)*3 # adjust step to try to hit stop exactly step = (stop-start)/(n-1) + len = itrunc(n) + else + len = itrunc(nf) end - len = itrunc(n) else n = nf len = iround(n) diff --git a/test/corelib.jl b/test/corelib.jl index 6eac3e93c6d1b..5210bf67354fa 100644 --- a/test/corelib.jl +++ b/test/corelib.jl @@ -29,6 +29,7 @@ r = [5:-1:1] @test length(.1:.1:.3) == 3 @test length(1.1:1.1:3.3) == 3 @test length(1.1:1.3:3) == 2 +@test length(1:1:1.8) == 1 let span = 5:20