diff --git a/Project.toml b/Project.toml index 79154e8..1dc7125 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Infinities" uuid = "e1ba4f0e-776d-440f-acd9-e1d2e9742647" authors = ["Sheehan Olver "] -version = "0.1.8" +version = "0.1.9" [compat] Aqua = "0.8" diff --git a/src/Infinities.jl b/src/Infinities.jl index 0eee1f8..1706a27 100644 --- a/src/Infinities.jl +++ b/src/Infinities.jl @@ -68,6 +68,8 @@ angle(x::RealInfinity) = π*signbit(x) string(y::RealInfinity) = signbit(y) ? "-∞" : "+∞" show(io::IO, y::RealInfinity) = print(io, string(y)) +Base.to_index(i::RealInfinity) = convert(Integer, i) + ####### # ComplexInfinity ####### diff --git a/test/runtests.jl b/test/runtests.jl index 5922f4e..84ee6eb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -203,6 +203,8 @@ using Aqua @test convert(Float16, -∞) ≡ Float16(-∞) ≡ -Inf16 @test convert(BigFloat, -∞)::BigFloat == BigFloat(-∞)::BigFloat == -BigFloat(Inf) end + + @test Base.to_index(RealInfinity()) ≡ ℵ₀ end @testset "ComplexInfinity" begin