Skip to content

Commit

Permalink
Fix bugs for x^Val and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed Mar 29, 2017
1 parent 4fe28fb commit 2283098
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,9 @@ end
@inline ^(x::Float64, y::Integer) = x ^ Float64(y)
@inline ^(x::Float32, y::Integer) = x ^ Float32(y)
@inline ^(x::Float16, y::Integer) = Float16(Float32(x) ^ Float32(y))
@inline ^{p}(x::Float16, ::Type{Val{p}}) = Float16(Float32(x) ^ Val{p})
@inline ^{p}(x::Float16, ::Type{Val{p}}) = Float16(x ^ p)
@inline ^{p}(x::Float32, ::Type{Val{p}}) = Float32(x ^ p)
@inline ^{p}(x::Float64, ::Type{Val{p}}) = Float64(x ^ p)

function angle_restrict_symm(theta)
const P1 = 4 * 7.8539812564849853515625e-01
Expand Down
1 change: 1 addition & 0 deletions test/float16.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ g = Float16(1.)
@test f*g === Float16(2f0)
@test f/g === Float16(2f0)
@test f^g === Float16(2f0)
@test f^Val{1} === Float16(2f0)
@test f^-g === Float16(0.5f0)

@test f + 2 === Float16(4f0)
Expand Down
2 changes: 2 additions & 0 deletions test/math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ end
@test e < big(20//6)
@test e^pi == exp(pi)
@test e^2 == exp(2)
@test e^Val{2} == exp(2)
@test e^2.4 == exp(2.4)
@test e^(2//3) == exp(2//3)

Expand Down Expand Up @@ -128,6 +129,7 @@ end
yi = 4
@testset "Random values" begin
@test x^y big(x)^big(y)
@test x^Val{1} === x
@test x^yi big(x)^yi
@test acos(x) acos(big(x))
@test acosh(1+x) acosh(big(1+x))
Expand Down

0 comments on commit 2283098

Please sign in to comment.