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

Float32/16 raised to an integer's typemin throws a DomainError #57464

Open
mbarbar opened this issue Feb 19, 2025 · 1 comment · May be fixed by #57488
Open

Float32/16 raised to an integer's typemin throws a DomainError #57464

mbarbar opened this issue Feb 19, 2025 · 1 comment · May be fixed by #57488
Labels
bug Indicates an unexpected problem or unintended behavior maths Mathematical functions

Comments

@mbarbar
Copy link

mbarbar commented Feb 19, 2025

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
Copy link
Member

NHDaly commented Feb 19, 2025

(this reproduces on master)

@nsajko nsajko added the maths Mathematical functions label Feb 20, 2025
kuszmaul added a commit to RelationalAI/julia that referenced this issue Feb 21, 2025
@kuszmaul kuszmaul linked a pull request Feb 21, 2025 that will close this issue
@LilithHafner LilithHafner added the bug Indicates an unexpected problem or unintended behavior label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior maths Mathematical functions
Projects
None yet
4 participants