Skip to content

Commit

Permalink
typemin, typemax for irrationals
Browse files Browse the repository at this point in the history
Fixes #36978
  • Loading branch information
nsajko committed Aug 12, 2023
1 parent 15b590b commit 1bc3c31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions base/irrationals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ See also [`AbstractIrrational`](@ref).
"""
struct Irrational{sym} <: AbstractIrrational end

typemin(::Type{T}) where {T<:Irrational} = T()
typemax(::Type{T}) where {T<:Irrational} = T()

show(io::IO, x::Irrational{sym}) where {sym} = print(io, sym)

function show(io::IO, ::MIME"text/plain", x::Irrational{sym}) where {sym}
Expand Down
6 changes: 6 additions & 0 deletions test/numbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3123,3 +3123,9 @@ end
end

end

@testset "irrational special values" begin
for v (π, ℯ, γ, catalan, φ)
@test v === typemin(v) === typemax(v)
end
end

0 comments on commit 1bc3c31

Please sign in to comment.