Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (-Inf)^-1 inconsistency #55875

Merged
merged 3 commits into from
Feb 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,8 @@ end
# this method is only reliable for -2^20 < n < 2^20 (cf. #53881 #53886)
@assume_effects :terminates_locally @noinline function pow_body(x::Float64, n::Integer)
y = 1.0
xnlo = ynlo = 0.0
xnlo = -0.0
ynlo = 0.0
n == 3 && return x*x*x # keep compatibility with literal_pow
if n < 0
rx = inv(x)
Expand Down
14 changes: 13 additions & 1 deletion test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,19 @@ end
@test E^n == Inf
@test E^float(n) == Inf

# #55633
# issue #55831
@testset "literal pow zero sign" begin
@testset "T: $T" for T ∈ (Float16, Float32, Float64, BigFloat)
@testset "literal `-1`" begin
@test -0.0 === Float64(T(-Inf)^-1)
end
@testset "`Int(-1)`" begin
@test -0.0 === Float64(T(-Inf)^Int(-1))
end
end
end

# issue #55633
struct Issue55633_1 <: Number end
struct Issue55633_3 <: Number end
struct Issue55633_9 <: Number end
Expand Down