Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zero(::Type{TwicePrecision}) for dimensionful quantities #36113

Merged
merged 1 commit into from
Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion base/twiceprecision.jl
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ big(x::TwicePrecision) = big(x.hi) + big(x.lo)

-(x::TwicePrecision) = TwicePrecision(-x.hi, -x.lo)

zero(::Type{TwicePrecision{T}}) where {T} = TwicePrecision{T}(0, 0)
function zero(::Type{TwicePrecision{T}}) where {T}
z = zero(T)
TwicePrecision{T}(z, z)
end

# Arithmetic

Expand Down
1 change: 1 addition & 0 deletions test/ranges.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ end
@test_throws ErrorException("Int is incommensurate with PhysQuantity") x*2 # not a MethodError for convert
@test x.hi/2 === PhysQuantity{1}(2.0)
@test_throws ErrorException("Int is incommensurate with PhysQuantity") x/2
@test zero(typeof(x)) === Base.TwicePrecision(PhysQuantity{1}(0.0))
end
@testset "ranges" begin
@test size(10:1:0) == (0,)
Expand Down