Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "NaNMath"
uuid = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
repo = "https://github.com/JuliaMath/NaNMath.jl.git"
authors = ["Miles Lubin"]
version = "1.0.2"
version = "1.0.3"

[deps]
OpenLibm_jll = "05823500-19ac-5b8b-9628-191a04bc5112"
Expand Down
4 changes: 4 additions & 0 deletions src/NaNMath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ pow(x::Float32, y::Float32) = ccall((:powf,libm), Float32, (Float32,Float32), x,
pow(x::Number, y::Number) = pow(promote(x, y)...)
pow(x::T, y::T) where {T<:Number} = pow(float(x), float(y))

# The following combinations are safe, so we can fall back to ^
pow(x::Number, y::Integer) = x^y
pow(x::Complex, y::Complex) = x^y

"""
NaNMath.sum(A)

Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ using Test
@test isnan(NaNMath.pow(-1.5f0,2.3f0))
@test isnan(NaNMath.pow(-1.5,2.3f0))
@test isnan(NaNMath.pow(-1.5f0,2.3))
@test NaNMath.pow(-1,2) isa Float64
@test NaNMath.pow(-1.5f0,2) isa Float32
@test NaNMath.pow(-1.5f0,2//1) isa Float32
@test NaNMath.pow(-1.5f0,2.3f0) isa Float32
Expand All @@ -16,6 +15,11 @@ using Test
@test NaNMath.pow(-1.5,2//1) isa Float64
@test NaNMath.pow(-1.5,2.3f0) isa Float64
@test NaNMath.pow(-1.5,2.3) isa Float64
@test NaNMath.pow(-1,2) === 1
@test NaNMath.pow(2,2) === 4
@test NaNMath.pow(1.0, 1.0+im) === 1.0 + 0.0im
@test NaNMath.pow(1.0+im, 1) === 1.0 + 1.0im
@test NaNMath.pow(1.0+im, 1.0) === 1.0 + 1.0im
@test isnan(NaNMath.sqrt(-5))
@test NaNMath.sqrt(5) == Base.sqrt(5)
@test isnan(NaNMath.sqrt(-3.2f0)) && NaNMath.sqrt(-3.2f0) isa Float32
Expand Down
Loading