78
78
function Base. promote_rule (:: Type{<:FixedRational{T1}} , :: Type{Rational{T2}} ) where {T1,T2}
79
79
return Rational{promote_type (T1,T2)}
80
80
end
81
- function Base. promote_rule (:: Type{<:FixedRational{T1}} , :: Type{T2} ) where {T1,T2}
81
+ function Base. promote_rule (:: Type{<:FixedRational{T1}} , :: Type{T2} ) where {T1,T2<: Real }
82
82
return promote_type (Rational{T1}, T2)
83
83
end
84
-
85
- # Want to consume integers:
86
- Base . promote (x :: Integer , y :: F ) where {F <: FixedRational } = ( F (x), y)
87
- Base . promote (x :: F , y :: Integer ) where {F <: FixedRational } = reverse ( promote (y, x))
84
+ function Base . promote_rule ( :: Type{F} , :: Type{<:Integer} ) where {F <: FixedRational }
85
+ # Want to consume integers:
86
+ return F
87
+ end
88
88
89
89
Base. string (x:: FixedRational ) =
90
90
let
@@ -93,7 +93,6 @@ Base.string(x::FixedRational) =
93
93
return string (div (x. num, g)) * " //" * string (div (denom (x), g))
94
94
end
95
95
Base. show (io:: IO , x:: FixedRational ) = print (io, string (x))
96
- Base. zero (:: Type{F} ) where {F<: FixedRational } = unsafe_fixed_rational (0 , eltype (F), val_denom (F))
97
96
98
97
tryrationalize (:: Type{F} , x:: F ) where {F<: FixedRational } = x
99
98
tryrationalize (:: Type{F} , x:: Union{Rational,Integer} ) where {F<: FixedRational } = convert (F, x)
0 commit comments