From aef9ae3e22bd4aaee9fb99859de07b88d62d07b9 Mon Sep 17 00:00:00 2001 From: OlivierHnt <38465572+OlivierHnt@users.noreply.github.com> Date: Fri, 31 May 2024 23:36:05 +0200 Subject: [PATCH] Add missing methods --- src/intervals/exact_literals.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/intervals/exact_literals.jl b/src/intervals/exact_literals.jl index 6cf65198c..75aa85ec0 100644 --- a/src/intervals/exact_literals.jl +++ b/src/intervals/exact_literals.jl @@ -60,6 +60,18 @@ _value(x::ExactReal) = x.value # hook for interval constructor Base.to_index(i::ExactReal{<:Integer}) = i.value +Base.zero(::Type{ExactReal{T}}) where {T<:Real} = ExactReal(zero(T)) +Base.zero(::ExactReal{T}) where {T<:Real} = zero(ExactReal{T}) + +Base.zero(::Type{Complex{ExactReal{T}}}) where {T<:Real} = complex(zero(ExactReal{T}), zero(ExactReal{T})) +Base.zero(::Complex{ExactReal{T}}) where {T<:Real} = zero(Complex{ExactReal{T}}) + +Base.one(::Type{ExactReal{T}}) where {T<:Real} = ExactReal(one(T)) +Base.one(::ExactReal{T}) where {T<:Real} = one(ExactReal{T}) + +Base.one(::Type{Complex{ExactReal{T}}}) where {T<:Real} = complex(one(ExactReal{T}), zero(ExactReal{T})) +Base.one(::Complex{ExactReal{T}}) where {T<:Real} = one(Complex{ExactReal{T}}) + # conversion and promotion Base.convert(::Type{ExactReal{T}}, x::ExactReal{T}) where {T<:Real} = x