You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
^(x::T, p::T) where {T<:Integer} =power_by_squaring(x,p)
julia> Base.power_by_squaring(2,-1)
ERROR: DomainError with -1:
Cannot raise an integer x to a negative power -1.
Make x or -1 a float by adding a zero decimal (e.g., 2.0^-1 or 2^-1.0 instead of 2^-1)or write 1/x^1, float(x)^-1, x^float(-1) or (x//1)^-1.
Stacktrace:
[1] throw_domerr_powbysq(::Int64, p::Int64)
@ Base .\intfuncs.jl:265
[2] power_by_squaring(x_::Int64, p::Int64)
@ Base .\intfuncs.jl:286
[3] top-level scope
@ REPL[79]:1
…w` case. (#53713)
The macros `@which`, `@edit`, `@functionloc`, `@less` from `InteractiveUtils`, if
applied to the case of literal powers, like `a^12` or `2^-1` used to direct the
user to function `^`, while the compiler generates code for `Base.literal_pow`.
Now the user is shown the code the compiler generates.
Fixes#53691Fixes#43337Fixes#21014
Co-authored-by: Matt Bauman <[email protected]>
julia/base/intfuncs.jl
Line 348 in 1ba83f0
It's because
2^(-1)
is done throughliteral_pow
.@code_lowered
and@less
have the same problem.The text was updated successfully, but these errors were encountered: