Skip to content

Commit c75a720

Browse files
authored
Support iseven and isodd (#76)
1 parent e6ae95b commit c75a720

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Static"
22
uuid = "aedffcd0-7271-4cad-89d0-dc628f76c6d3"
33
authors = ["chriselrod", "ChrisRackauckas", "Tokazama"]
4-
version = "0.7.5"
4+
version = "0.7.6"
55

66
[deps]
77
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"

src/Static.jl

+3
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ Base.inv(x::StaticNumber{N}) where {N} = one(x) / x
312312
@inline Base.iszero(@nospecialize x::StaticNumber) = false
313313
@inline Base.isone(::Union{One, FloatOne, True}) = true
314314
@inline Base.isone(@nospecialize x::StaticNumber) = false
315+
@inline Base.iseven(@nospecialize x::StaticNumber) = iseven(known(x))
316+
@inline Base.isodd(@nospecialize x::StaticNumber) = isodd(known(x))
317+
315318

316319
Base.AbstractFloat(x::StaticNumber) = StaticFloat64(x)
317320

test/runtests.jl

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ end
2929
@test @inferred(one(StaticInt)) === StaticInt(1)
3030
@test @inferred(zero(StaticInt)) === StaticInt(0) === StaticInt(StaticInt(Val(0)))
3131
@test eltype(one(StaticInt)) <: Int
32+
@test @inferred(isodd(one(StaticInt)))
33+
@test @inferred(iseven(zero(StaticInt)))
3234

3335
x = StaticInt(1)
3436
y = static(3)

0 commit comments

Comments
 (0)