From bc014ed2ac7f913bbeb564cd78ba29801894db29 Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Tue, 12 Dec 2023 17:40:36 +0530 Subject: [PATCH] to_index for RealInfinity --- Project.toml | 2 +- src/Infinities.jl | 2 +- test/runtests.jl | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 2219a90..c6dd2c8 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 3bd8cd7..e6ff365 100644 --- a/src/Infinities.jl +++ b/src/Infinities.jl @@ -243,7 +243,7 @@ max(::RealInfinity, ::Infinity) = ∞ min(::Infinity, x::RealInfinity) = x max(::Infinity, x::RealInfinity) = ∞ - +Base.to_index(i::RealInfinity) = convert(Integer, i) ###### # ComplexInfinity diff --git a/test/runtests.jl b/test/runtests.jl index 8768545..695317f 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -205,6 +205,8 @@ end @test convert(Float16, -∞) ≡ Float16(-∞) ≡ -Inf16 @test convert(BigFloat, -∞)::BigFloat == BigFloat(-∞)::BigFloat == -BigFloat(Inf) end + + @test Base.to_index(RealInfinity()) ≡ ℵ₀ end @testset "ComplexInfinity" begin