Why doesn't `^` promote its arguments?

You are right, / will always give Float64.

Regarding the discussions about integer exponents and integer overflow, note that I don’t have a problem with unchecked integer overflow. 2^63 equals -9223372036854775808, which is totally acceptable and unsurprising, I’m just saying that Int8(2)^63 should give the same result, because one of the arguments of ^, namely 63, is of type Int64 (at least on my system). On the other hand, Int8(2)^Int8(63) should give 0.

I also think that my discussion does not involve Floats at all. It seems that powers with float arguments are handled by a different function:

julia> @which 3.0^2
^(x::Float64, y::Integer) in Base.Math at math.jl:922

whereas

julia> @which 3^2
^(x::T, p::T) where T<:Integer in Base at intfuncs.jl:290

So, by changing the power_by_squaring() function, there wouldn’t be a performance decrease stemming from promoting integer exponents to floats.

Anyway, as @stephancb said, changing power_by_squaring() would be breaking, at this point. I guess I’ll just note down this behaviour and be careful with my code :slight_smile: