Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ uuid = "e1ba4f0e-776d-440f-acd9-e1d2e9742647"
authors = ["Sheehan Olver <[email protected]>"]
version = "0.1.4"

[deps]
Static = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"

[compat]
Static = "0.4"
julia = "1"

[extras]
Expand Down
15 changes: 8 additions & 7 deletions src/Infinities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ show(io::IO, y::RealInfinity) = print(io, string(y))
isless(x::RealInfinity, y::RealInfinity) = signbit(x) && !signbit(y)
for Typ in (:Number, :Real, :Integer, :AbstractFloat)
@eval begin
isless(x::RealInfinity, y::$Typ) = signbit(x) && y ≠ -∞
isless(x::$Typ, y::RealInfinity) = !signbit(y) && x ≠ 
isless(x::RealInfinity, y::$Typ) = signbit(x) && y ≠ -∞
isless(x::$Typ, y::RealInfinity) = !signbit(y) && x ≠
+(::$Typ, y::RealInfinity) = y
+(y::RealInfinity, ::$Typ) = y
-(y::RealInfinity, ::$Typ) = y
Expand Down Expand Up @@ -217,7 +217,7 @@ end
-(y::RealInfinity) = RealInfinity(!y.signbit)

function +(x::RealInfinity, y::RealInfinity)
x == y || throw(ArgumentError("Angles must be the same to add ∞"))
x == y || throw(ArgumentError("Angles must be the same to add ∞"))
x
end

Expand Down Expand Up @@ -317,13 +317,13 @@ show(io::IO, x::ComplexInfinity) = print(io, "exp($(x.signbit)*im*π)∞")
==(y::Number, x::ComplexInfinity) = x == y

isless(x::ComplexInfinity{Bool}, y::ComplexInfinity{Bool}) = x.signbit && !y.signbit
isless(x::Number, y::ComplexInfinity{Bool}) = !y.signbit && x ≠ 
isless(x::ComplexInfinity{Bool}, y::Number) = x.signbit && y ≠ -∞
isless(x::Number, y::ComplexInfinity{Bool}) = !y.signbit && x ≠
isless(x::ComplexInfinity{Bool}, y::Number) = x.signbit && y ≠ -∞

-(y::ComplexInfinity{B}) where B<:Integer = sign(y) == 1 ? ComplexInfinity(one(B)) : ComplexInfinity(zero(B))

function +(x::ComplexInfinity, y::ComplexInfinity)
x == y || throw(ArgumentError("Angles must be the same to add ∞"))
x == y || throw(ArgumentError("Angles must be the same to add ∞"))
promote_type(typeof(x),typeof(y))(x.signbit)
end

Expand Down Expand Up @@ -376,7 +376,7 @@ for OP in (:fld,:cld,:div)
end

min(x::ComplexInfinity{B}, y::ComplexInfinity{B}) where B<:Integer = sign(x) == -1 ? x : y
max(x::ComplexInfinity{B}, ::ComplexInfinity{B}) where B<:Integer = sign(x) == 1 ? x : y
max(x::ComplexInfinity{B}, y::ComplexInfinity{B}) where B<:Integer = sign(x) == 1 ? x : y
min(x::Real, y::ComplexInfinity{B}) where B<:Integer = sign(y) == 1 ? x : y
min(x::ComplexInfinity{B}, y::Real) where B<:Integer = min(y,x)
max(x::Real, y::ComplexInfinity{B}) where B<:Integer = sign(y) == 1 ? y : x
Expand All @@ -400,4 +400,5 @@ Base.hash(::Infinity) = 0x020113134b21797f # made up


include("cardinality.jl")
include("static.jl")
end # module
Loading