@@ -406,20 +406,19 @@ function Base.checked_sub(x::T, y::T) where {T<:FD}
406
406
b && Base. Checked. throw_overflowerr_binaryop (:- , x, y)
407
407
return reinterpret (T, z)
408
408
end
409
- function Base. checked_mul (x:: FD{T,f} , y:: FD{T,f} ) where {T, f}
409
+ function Base. checked_mul (x:: FD{T,f} , y:: FD{T,f} ) where {T<: Integer , f}
410
410
powt = coefficient (FD{T, f})
411
411
quotient, remainder = fldmodinline (widemul (x. i, y. i), powt)
412
412
v = _round_to_nearest (quotient, remainder, powt)
413
413
typemin (T) <= v <= typemax (T) || Base. Checked. throw_overflowerr_binaryop (:* , x, y)
414
414
return reinterpret (FD{T, f}, T (v))
415
415
end
416
- function Base. checked_div (x:: FD{T,f} , y:: FD{T,f} ) where {T,f}
416
+ function Base. checked_div (x:: FD{T,f} , y:: FD{T,f} ) where {T<: Integer ,f}
417
417
C = coefficient (FD{T, f})
418
- v1 = div (promote (x . i, y . i) ... )
419
- v2 , b = Base. Checked. mul_with_overflow (C, v1 )
418
+ # Note: The div() will already throw for divide-by-zero and typemin(T) ÷ -1.
419
+ v , b = Base. Checked. mul_with_overflow (C, div (x . i, y . i) )
420
420
b && Base. Checked. throw_overflowerr_binaryop (:÷ , x, y)
421
- typemin (T) <= v2 <= typemax (T) || Base. Checked. throw_overflowerr_binaryop (:÷ , x, y)
422
- return reinterpret (FD{T, f}, T (v2))
421
+ return reinterpret (FD{T, f}, v)
423
422
end
424
423
425
424
# --------------------------
0 commit comments