Skip to content

Commit 0b840c7

Browse files
oscardssmithKristofferC
authored andcommitted
fix bug when error is infinite (#46436)
(cherry picked from commit c491e79)
1 parent 649f568 commit 0b840c7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

base/math.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,8 +1068,8 @@ end
10681068
xnlo += err
10691069
n >>>= 1
10701070
end
1071-
!isfinite(x) && return x*y
1072-
return muladd(x, y, muladd(y, xnlo, x*ynlo))
1071+
err = muladd(y, xnlo, x*ynlo)
1072+
return ifelse(isfinite(x) & isfinite(err), muladd(x, y, err), x*y)
10731073
end
10741074

10751075
function ^(x::Float32, n::Integer)

test/math.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,7 @@ end
13621362
end
13631363
# test for large negative exponent where error compensation matters
13641364
@test 0.9999999955206014^-1.0e8 == 1.565084574870928
1365+
@test 3e18^20 == Inf
13651366
end
13661367

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

0 commit comments

Comments
 (0)