-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Closed
Description
The implementation on current master (see below) claims to provide compatibility for overriding cld
/fld
, but actually doesn’t (at least in the case of HalfIntegers.jl, which is currently broken on master for this reason).
Lines 223 to 233 in 8707744
# These are kept for compatibility with external packages overriding fld/cld. | |
# In 2.0, packages should extend div(a,b,r) instead, in which case, these can | |
# be removed. | |
fld(x::Real, y::Real) = div(promote(x,y)..., RoundDown) | |
cld(x::Real, y::Real) = div(promote(x,y)..., RoundUp) | |
fld(x::Signed, y::Unsigned) = div(x, y, RoundDown) | |
fld(x::Unsigned, y::Signed) = div(x, y, RoundDown) | |
cld(x::Signed, y::Unsigned) = div(x, y, RoundUp) | |
cld(x::Unsigned, y::Signed) = div(x, y, RoundUp) | |
fld(x::T, y::T) where {T<:Real} = throw(MethodError(div, (x, y, RoundDown))) | |
cld(x::T, y::T) where {T<:Real} = throw(MethodError(div, (x, y, RoundUp))) |
HalfIntegers.jl defines fld(x::T, y::T) where T<:HalfInteger
. Due to the changes on master, this method isn’t called anymore when fld
is called with two different types of HalfInteger
s. In order for the above code to fulfill its purpose, the first two and last two methods above could be replaced with
fld(x::Real, y::Real) = fld(promote(x,y)...)
cld(x::Real, y::Real) = cld(promote(x,y)...)
fld(x::T, y::T) where {T<:Real} = div(x, y, RoundDown)
cld(x::T, y::T) where {T<:Real} = div(x, y, RoundUp)
Metadata
Metadata
Assignees
Labels
No labels