Skip to content

Commit

Permalink
fix bug when error is infinite (#46436)
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardssmith committed Aug 26, 2022
1 parent bea7b6f commit c491e79
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1176,8 +1176,8 @@ end
xnlo += err
n >>>= 1
end
!isfinite(x) && return x*y
return muladd(x, y, muladd(y, xnlo, x*ynlo))
err = muladd(y, xnlo, x*ynlo)
return ifelse(isfinite(x) & isfinite(err), muladd(x, y, err), x*y)
end

function ^(x::Float32, n::Integer)
Expand Down
1 change: 1 addition & 0 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,7 @@ end
end
# test for large negative exponent where error compensation matters
@test 0.9999999955206014^-1.0e8 == 1.565084574870928
@test 3e18^20 == Inf
end

# Test that sqrt behaves correctly and doesn't exhibit fp80 double rounding.
Expand Down

0 comments on commit c491e79

Please sign in to comment.