a=[0.0, -0.0, -0.0, -3.0, 1.0, -0.0]
b=findall(isequal(0),a) #can only identify 0
c=findall(isequal(-0),a) #only for -0
bc=findall(isequal(-0)||isequal(0),a)
#how can I pick all 0 in order in bc instead of
#concatennating and arrange b and c?
Hi there! Perhaps you want:
b=findall(iszero, a)
3 Likes
You sure about that? -0
is the Int
0
.
Note that this has nothing to do with find*
, it’s simply because that’s what you asked for from isequal
.
julia> isequal(0.0, -0.0)
false
julia> isequal(0.0, 0.0)
true
If you don’t want this behavior, you simply need to provide the condition that you expect. ==
should compare -0.0
and 0.0
equal so you can just do
julia> findall(==(0), a)
4-element Array{Int64,1}:
1
2
3
6
4 Likes