From 3bf4701ea1a04f3224d3e65dab39852416001d2f Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Sat, 11 Feb 2017 06:19:08 -0600 Subject: [PATCH] Fix an ambiguity on julia 0.6 --- src/normed.jl | 3 +-- test/normed.jl | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/normed.jl b/src/normed.jl index dffc2bbc..416f314e 100644 --- a/src/normed.jl +++ b/src/normed.jl @@ -36,7 +36,7 @@ zero(x::Normed) = zero(typeof(x)) rawone(v) = reinterpret(one(v)) # Conversions -convert{T<:Normed}(::Type{T}, x::T) = x +convert{T<:Unsigned,f}(::Type{Normed{T,f}}, x::Normed{T,f}) = x convert{T1<:Unsigned,T2<:Unsigned,f}(::Type{Normed{T1,f}}, x::Normed{T2,f}) = Normed{T1,f}(convert(T1, x.i), 0) function convert{T<:Unsigned,T2<:Unsigned,f}(::Type{Normed{T,f}}, x::Normed{T2}) U = Normed{T,f} @@ -45,7 +45,6 @@ function convert{T<:Unsigned,T2<:Unsigned,f}(::Type{Normed{T,f}}, x::Normed{T2}) reinterpret(U, _unsafe_trunc(T, y)) end convert{U<:Normed}(::Type{U}, x::Real) = _convert(U, rawtype(U), x) -convert{T1,T2,f}(::Type{Normed{T1,f}}, x::Normed{T2,f}) = Normed{T1,f}(convert(T1, x.i), 0) convert(::Type{N0f16}, x::N0f8) = reinterpret(N0f16, convert(UInt16, 0x0101*reinterpret(x))) function _convert{U<:Normed,T}(::Type{U}, ::Type{T}, x) diff --git a/test/normed.jl b/test/normed.jl index d6a66425..ba20da8a 100644 --- a/test/normed.jl +++ b/test/normed.jl @@ -65,6 +65,7 @@ end @test_throws ArgumentError convert(Normed{UInt128,100}, 10.0^9) x = N0f8(0.5) +@test convert(N0f8, x) === x @test isfinite(x) == true @test isnan(x) == false @test isinf(x) == false