Skip to content

Commit

Permalink
fix T(x::T) ambiguity (closes #85)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Jan 11, 2019
1 parent ad5f8ad commit fb4928d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/DecFP.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ for w in (32,64,128)
Ti = Symbol(string("UInt",w))
@eval struct $BID <: DecimalFloatingPoint
x::$Ti
$BID(x) = convert($BID, x)
$BID(x::Number) = convert($BID, x)
Base.reinterpret(::Type{$BID}, x::$Ti) = new(x)
end
# fix method ambiguities:
@eval $BID(x::Rational{T}) where {T} = convert($BID, x)
end

Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ for T in (Dec32, Dec64, Dec128)

@test typeof(xd * pi) == T
@test typeof((xd+yd*im)*pi) == Complex{T}

# issue #85
@test T(1.5) == T(T(1.5))
end

@test unsafe_load(DecFP.flags[]) == 0
Expand Down

0 comments on commit fb4928d

Please sign in to comment.