Skip to content

Commit 78e45dc

Browse files
committed
Fix ambiguity in _widemul(Int256, UInt256)
1 parent 7756238 commit 78e45dc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/FixedPointDecimals.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,16 @@ end
123123
# Custom widemul implementation to avoid the cost of widening to BigInt.
124124
# FD{Int128} operations should widen to 256 bits internally, rather than to a BigInt.
125125
const BitInteger128 = Union{Int128, UInt128}
126-
_widemul(x, y) = widemul(x, y)
127-
_widemul(x::BitInteger128, y) = _widemul(promote(x, y)...)
128-
_widemul(x, y::BitInteger128) = _widemul(promote(x, y)...)
129-
_widemul(x::Int128, y::Int128) = BitIntegers.Int256(x) * BitIntegers.Int256(y)
130-
_widemul(x::UInt128, y::UInt128) = BitIntegers.UInt256(x) * BitIntegers.UInt256(y)
126+
_widemul(x, y) = _widen(x) * _widen(y)
127+
_widemul(x::Signed,y::Unsigned) = _widen(x) * signed(_widen(y))
128+
_widemul(x::Unsigned,y::Signed) = signed(_widen(x)) * _widen(y)
131129

132130
# Custom widen implementation to avoid the cost of widening to BigInt.
133131
# FD{Int128} operations should widen to 256 bits internally, rather than to a BigInt.
134132
_widen(::Type{Int128}) = BitIntegers.Int256
135133
_widen(::Type{UInt128}) = BitIntegers.UInt256
136-
_widen(t) = widen(t)
134+
_widen(t::Type) = widen(t)
135+
_widen(x::T) where {T} = (_widen(T))(x)
137136

138137

139138
(::Type{T})(x::Real) where {T <: FD} = convert(T, x)

0 commit comments

Comments
 (0)