Skip to content

Commit e40c32c

Browse files
committed
Remove duplicate code in promotions
1 parent 243017d commit e40c32c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/fixed_rational.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ Base.convert(::Type{Rational}, x::F) where {F<:FixedRational} = Rational{eltype(
4444
Base.convert(::Type{AF}, x::F) where {AF<:AbstractFloat,F<:FixedRational} = convert(AF, x.num) / convert(AF, denom(F))
4545
Base.round(::Type{T}, x::F) where {T,F<:FixedRational} = div(convert(T, x.num), convert(T, denom(F)), RoundNearest)
4646
Base.promote(x::Integer, y::F) where {F<:FixedRational} = (F(x), y)
47-
Base.promote(x::F, y::Integer) where {F<:FixedRational} = (x, F(y))
47+
Base.promote(x::F, y::Integer) where {F<:FixedRational} = reverse(promote(y, x))
4848
Base.promote(x, y::F) where {F<:FixedRational} = promote(x, convert(Rational, y))
49-
Base.promote(x::F, y) where {F<:FixedRational} = promote(convert(Rational, x), y)
49+
Base.promote(x::F, y) where {F<:FixedRational} = reverse(promote(y, x))
5050
Base.show(io::IO, x::F) where {F<:FixedRational} = show(io, convert(Rational, x))
5151
Base.zero(::Type{F}) where {F<:FixedRational} = unsafe_fixed_rational(0, eltype(F), val_denom(F))
5252

0 commit comments

Comments
 (0)