Skip to content

Commit b3a99ad

Browse files
committed
Export and test Base.iszero
1 parent f864b22 commit b3a99ad

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

base/exports.jl

+1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ export
360360
isreal,
361361
isimag,
362362
issubnormal,
363+
iszero,
363364
lcm,
364365
ldexp,
365366
leading_ones,

doc/src/stdlib/numbers.md

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Base.issubnormal
6767
Base.isfinite
6868
Base.isinf
6969
Base.isnan
70+
Base.iszero
7071
Base.nextfloat
7172
Base.prevfloat
7273
Base.isinteger

test/numbers.jl

+16
Original file line numberDiff line numberDiff line change
@@ -2864,3 +2864,19 @@ let types = (Base.BitInteger_types..., BigInt, Bool)
28642864
end
28652865

28662866
@test !isempty(complex(1,2))
2867+
2868+
@testset "iszero" begin
2869+
# Numeric scalars
2870+
for T in Iterators.flatten(subtypes.([AbstractFloat, Signed, Unsigned]))
2871+
@test iszero(T(0))
2872+
@test iszero(Complex{T}(0))
2873+
end
2874+
@test iszero(BigFloat(0))
2875+
@test !iszero(nextfloat(BigFloat(0)))
2876+
@test iszero(BigInt(0))
2877+
@test iszero(0//1)
2878+
2879+
# Array reduction
2880+
@test !iszero([0, 1, 2, 3])
2881+
@test iszero(zeros(Int, 5))
2882+
end

0 commit comments

Comments
 (0)