Skip to content

Commit

Permalink
Add missing methods
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHnt committed May 31, 2024
1 parent 09af634 commit aef9ae3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/intervals/exact_literals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aef9ae3

Please sign in to comment.