Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 src/expint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ function li(x::Real)
if x < 0
throw(DomainError(x, "negative argument, convert to complex first"))
elseif x == 0
return 0
return zero(typeof(x))
else
return expinti(log(x))
end
Expand Down
11 changes: 7 additions & 4 deletions test/expint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,11 @@ expinti_real(x) = invoke(expinti, Tuple{Real}, x)
end

@testset "Logarithmic integral function" begin
@test li(0.0) == 0
@test li(1.0) == -Inf
@test li(Inf) === Inf
@test li(2) ≈ 1.0451637801174927
@test @inferred(li(0.0)) === 0.0 # float 64
@test @inferred(li(0.0f0)) === 0.0f0 # float 32
@test @inferred(li(Float16(0))) === Float16(0) # float 16

@test @inferred(li(1.0)) === -Inf
@test @inferred(li(Inf)) === Inf
@test @inferred(li(2)) ≈ 1.0451637801174927 # this errors idk why
end
Loading