Skip to content

Commit cb751af

Browse files
committed
Fix promotion on 0.7
1 parent c238d42 commit cb751af

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/FixedPointNumbers.jl

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Base: ==, <, <=, -, +, *, /, ~, isapprox,
1010
zero, oneunit, one, typemin, typemax, realmin, realmax, eps, sizeof, reinterpret,
1111
float, trunc, round, floor, ceil, bswap,
1212
div, fld, rem, mod, mod1, fld1, min, max, minmax,
13-
start, next, done, r_promote, reducedim_init, rand
13+
start, next, done, reducedim_init, rand
1414
if isdefined(Base, :rem1)
1515
import Base: rem1
1616
end
@@ -133,8 +133,12 @@ sizeof(::Type{T}) where {T <: FixedPoint} = sizeof(rawtype(T))
133133

134134
# Promotions for reductions
135135
const Treduce = Float64
136-
r_promote(::typeof(+), x::FixedPoint{T}) where {T} = Treduce(x)
137-
r_promote(::typeof(*), x::FixedPoint{T}) where {T} = Treduce(x)
136+
if isdefined(Base, :r_promote)
137+
Base.r_promote(::typeof(+), x::FixedPoint{T}) where {T} = Treduce(x)
138+
Base.r_promote(::typeof(*), x::FixedPoint{T}) where {T} = Treduce(x)
139+
else
140+
Base.promote_sys_size(::Type{<:FixedPoint}) = Treduce
141+
end
138142

139143
reducedim_init(f::typeof(identity),
140144
op::typeof(+),

0 commit comments

Comments
 (0)