@@ -445,7 +445,7 @@ overflow/underflow did in fact happen. Throws a DivideError on divide-by-zero.
445
445
function div_with_overflow (x:: FD{T,f} , y:: FD{T,f} ) where {T<: Integer ,f}
446
446
C = coefficient (FD{T, f})
447
447
# This case will break the fld call below.
448
- if T <: Signed && x . i == typemin (T) && y . i == - 1
448
+ if y . i == - 1 && T <: Signed && hasmethod ( typemin, (Type{T},)) && x . i == typemin (T)
449
449
# To perform the div and overflow means reaching the max and adding 1, so typemin.
450
450
return (x, true )
451
451
end
@@ -470,7 +470,7 @@ See also:
470
470
function fld_with_overflow (x:: FD{T,f} , y:: FD{T,f} ) where {T<: Integer ,f}
471
471
C = coefficient (FD{T, f})
472
472
# This case will break the fld call below.
473
- if T <: Signed && x . i == typemin (T) && y . i == - 1
473
+ if y . i == - 1 && T <: Signed && hasmethod ( typemin, (Type{T},)) && x . i == typemin (T)
474
474
# To fld and overflow means reaching the max and adding 1, so typemin (x).
475
475
return (x, true )
476
476
end
@@ -513,7 +513,7 @@ function rdiv_with_overflow(x::Integer, y::FD{T, f}) where {T<:Integer, f}
513
513
return (reinterpret (FD{T,f}, rem (v, T)), v < typemin (T) || v > typemax (T))
514
514
end
515
515
function rdiv_with_overflow (x:: FD{T, f} , y:: Integer ) where {T<: Integer , f}
516
- if T <: Signed && x . i == typemin (T) && y == - 1
516
+ if y == - 1 && T <: Signed && hasmethod ( typemin, (Type{T},)) && x . i == typemin (T)
517
517
# typemin / -1 for signed integers wraps, giving typemin (x) again.
518
518
return (x, true )
519
519
end
0 commit comments