diff --git a/base/math.jl b/base/math.jl index 650fc6bc0cef0..0e5f9dd41bdca 100644 --- a/base/math.jl +++ b/base/math.jl @@ -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) diff --git a/test/math.jl b/test/math.jl index 7070fe63ba931..d9cfd411124ed 100644 --- a/test/math.jl +++ b/test/math.jl @@ -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