Skip to content

Commit

Permalink
Better fix of Rational-to-BigFloat ambiguity warning
Browse files Browse the repository at this point in the history
(reverts a85476b)
  • Loading branch information
carlobaldassi committed Apr 2, 2014
1 parent a85476b commit 005197a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/mpfr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ BigFloat(x::Union(Float16,Float32)) = BigFloat(float64(x))
BigFloat(x::Rational) = BigFloat(num(x)) / BigFloat(den(x))

convert(::Type{Rational}, x::BigFloat) = convert(Rational{BigInt}, x)
convert(::Type{BigFloat}, x::Rational) = BigFloat(x) # to resolve ambiguity
convert{S}(::Type{BigFloat}, x::Rational{S}) = BigFloat(x) # to resolve ambiguity
convert(::Type{BigFloat}, x::Real) = BigFloat(x)
convert(::Type{FloatingPoint}, x::BigInt) = BigFloat(x)

Expand Down
2 changes: 1 addition & 1 deletion base/rational.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ convert(::Type{Bool}, x::Rational) = (x!=0) # to resolve ambiguity
convert{T<:Integer}(::Type{T}, x::Rational) = (isinteger(x) ? convert(T, x.num) : throw(InexactError()))

convert(::Type{FloatingPoint}, x::Rational) = float(x.num)/float(x.den)
function convert{T<:FloatingPoint,S<:Integer}(::Type{T}, x::Rational{S})
function convert{T<:FloatingPoint,S}(::Type{T}, x::Rational{S})
P = promote_type(T,S)
convert(P,x.num)/convert(P,x.den)
end
Expand Down

0 comments on commit 005197a

Please sign in to comment.