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 Dec 23, 2023
1 parent 52ff558 commit 2fe4b51
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 @@ -3141,3 +3141,9 @@ end
@test n == G(F(n)) == F(G(n))
end
end

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

0 comments on commit 2fe4b51

Please sign in to comment.