JuliaMath / Infinities.jl

A Julia package for representing infinity in all its forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comparing `ℵ₀` and `∞`

putianyi889 opened this issue · comments

Does these mean ℵ₀ is strictly greater than while they are also equal? What is the purpose behind it?

@test ℵ₀ ==&&== ℵ₀

@test !(∞ < ℵ₀) && ℵ₀

@test min(∞,ℵ₀) min(ℵ₀,∞)
@test max(∞,ℵ₀) max(ℵ₀,∞) ℵ₀

https://github.com/JuliaLang/julia/blob/43d7f881f8e26eb4bb7ef3d6f84b378d28125325/base/promotion.jl#L532-L533

Where do you get "strictly greater than"?

It actually says "not strictly greater than"

because Julia base defines min and max as

min(x,y) = ifelse(y < x, y, x)
max(x,y) = ifelse(y < x, x, y)

so if min(x,y) == min(y,x) == x then x must be strictly less.

Not always:

julia> min(1.0, 1)
1.0

julia> min(1, 1.0)
1.0

It's because of promotion

min(x::Real, y::Real) = min(promote(x,y)...) # promotion.jl