Skip to content

Commit c491e79

Browse files
authored
fix bug when error is infinite (#46436)
1 parent bea7b6f commit c491e79

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
@@ -1176,8 +1176,8 @@ end
11761176
xnlo += err
11771177
n >>>= 1
11781178
end
1179-
!isfinite(x) && return x*y
1180-
return muladd(x, y, muladd(y, xnlo, x*ynlo))
1179+
err = muladd(y, xnlo, x*ynlo)
1180+
return ifelse(isfinite(x) & isfinite(err), muladd(x, y, err), x*y)
11811181
end
11821182

11831183
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)