Skip to content

Commit 6bfc193

Browse files
authored
Add ustrip() support to Base.TwicePrecision (#711)
Fixes #709
1 parent c333efe commit 6bfc193

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/range.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ _colon(::Any, ::Any, start::T, step, stop::T) where {T} =
115115
*(x::Base.TwicePrecision, y::Units) = Base.TwicePrecision(x.hi*y, x.lo*y)
116116
*(x::Base.TwicePrecision, y::Quantity) = (x * ustrip(y)) * unit(y)
117117
uconvert(y, x::Base.TwicePrecision) = Base.TwicePrecision(uconvert(y, x.hi), uconvert(y, x.lo))
118+
ustrip(x::Base.TwicePrecision) = Base.TwicePrecision(ustrip(x.hi), ustrip(x.lo))
118119
@inline upreferred(x::Base.TwicePrecision{T}) where T<:Number = x
119120
@inline upreferred(x::Base.TwicePrecision{T}) where T<:AbstractQuantity =
120121
uconvert(upreferred(unit(x)), x)

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,6 +1400,10 @@ end
14001400
@test_throws ArgumentError range(step=1m, length=5)
14011401
end
14021402
end
1403+
@testset ">> broadcast ustrip" begin
1404+
@test ustrip.(1:0.1:1.0) == 1:0.1:1.0
1405+
@test ustrip.(1m:0.1m:1.0m) == 1:0.1:1.0
1406+
end
14031407
end
14041408
@testset "> Arrays" begin
14051409
@testset ">> Array multiplication" begin

0 commit comments

Comments
 (0)