Skip to content

Commit 1f4f4fb

Browse files
authored
Merge pull request #21226 from JuliaLang/ksh/valexp
Fix bugs for x^Val and add tests
2 parents ec1dbd1 + f5e5ea5 commit 1f4f4fb

File tree

6 files changed

+3
-8
lines changed

6 files changed

+3
-8
lines changed

base/gmp.jl

-3
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,6 @@ end
443443
^(x::Integer, y::BigInt ) = bigint_pow(BigInt(x), y)
444444
^(x::Bool , y::BigInt ) = Base.power_by_squaring(x, y)
445445

446-
# override default inlining of x^2 and x^3 etc.
447-
^{p}(x::BigInt, ::Type{Val{p}}) = x^p
448-
449446
function powermod(x::BigInt, p::BigInt, m::BigInt)
450447
r = BigInt()
451448
ccall((:__gmpz_powm, :libgmp), Void,

base/irrationals.jl

-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ catalan
212212
for T in (Irrational, Rational, Integer, Number)
213213
^(::Irrational{:e}, x::T) = exp(x)
214214
end
215-
^{p}(::Irrational{:e}, ::Type{Val{p}}) = exp(p)
216215

217216
log(::Irrational{:e}) = 1 # use 1 to correctly promote expressions like log(x)/log(e)
218217
log(::Irrational{:e}, x::Number) = log(x)

base/math.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ end
698698
@inline ^(x::Float64, y::Integer) = x ^ Float64(y)
699699
@inline ^(x::Float32, y::Integer) = x ^ Float32(y)
700700
@inline ^(x::Float16, y::Integer) = Float16(Float32(x) ^ Float32(y))
701-
@inline ^{p}(x::Float16, ::Type{Val{p}}) = Float16(Float32(x) ^ Val{p})
701+
@inline literal_pow{p}(::typeof(^), x::Float16, ::Type{Val{p}}) = Float16(literal_pow(^,Float32(x),Val{p}))
702702

703703
function angle_restrict_symm(theta)
704704
const P1 = 4 * 7.8539812564849853515625e-01

base/mpfr.jl

-3
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,6 @@ end
504504
^(x::BigFloat, y::Integer) = typemin(Clong) <= y <= typemax(Clong) ? x^Clong(y) : x^BigInt(y)
505505
^(x::BigFloat, y::Unsigned) = typemin(Culong) <= y <= typemax(Culong) ? x^Culong(y) : x^BigInt(y)
506506

507-
# override default inlining of x^2 etc.
508-
^{p}(x::BigFloat, ::Type{Val{p}}) = x^p
509-
510507
for f in (:exp, :exp2, :exp10, :expm1, :cosh, :sinh, :tanh, :sech, :csch, :coth, :cbrt)
511508
@eval function $f(x::BigFloat)
512509
z = BigFloat()

test/float16.jl

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ g = Float16(1.)
6161
@test f*g === Float16(2f0)
6262
@test f/g === Float16(2f0)
6363
@test f^g === Float16(2f0)
64+
@test f^1 === Float16(2f0)
6465
@test f^-g === Float16(0.5f0)
6566

6667
@test f + 2 === Float16(4f0)

test/math.jl

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ end
128128
yi = 4
129129
@testset "Random values" begin
130130
@test x^y big(x)^big(y)
131+
@test x^1 === x
131132
@test x^yi big(x)^yi
132133
@test acos(x) acos(big(x))
133134
@test acosh(1+x) acosh(big(1+x))

0 commit comments

Comments
 (0)