-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviormathsMathematical functionsMathematical functions
Description
It shouldn't throw because there is generally no issue raising a Float to a negative power.
julia> x = Float32(1.1)
1.1f0
julia> y = typemin(Int64)
-9223372036854775808
julia> x ^ y
ERROR: DomainError with -9223372036854775808:
Cannot raise an integer x to a negative power -9223372036854775808.
Convert input to float.
Stacktrace:
[1] throw_domerr_powbysq(::Float64, p::Int64)
@ Base ./intfuncs.jl:262
[2] power_by_squaring(x_::Float64, p::Int64)
@ Base ./intfuncs.jl:286
[3] ^(x::Float32, n::Int64)
@ Base.Math ./math.jl:1280
[4] top-level scope
@ REPL[66]:1
julia> x ^ (y+1)
0.0f0
At some point there's a -exponent but -typemin(Int) == typemin(Int).
I've also opened #57463 but this goes through a different path (and anyway produce an incorrect result rather than an exception).
NHDaly
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviormathsMathematical functionsMathematical functions