# Whay operator "&" on two (the same?) bool vectors give others result?

**URL:** https://discourse.julialang.org/t/whay-operator-on-two-the-same-bool-vectors-give-others-result/1821
**Category:** General Usage
**Tags:** question
**Created:** [February 1, 2017, 3:00pm UTC](https://discourse.julialang.org/t/whay-operator-on-two-the-same-bool-vectors-give-others-result/1821 "2017-02-01T15:00:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)
#### Post date: [February 1, 2017, 3:00pm UTC](https://discourse.julialang.org/t/whay-operator-on-two-the-same-bool-vectors-give-others-result/1821/1 "2017-02-01T15:00:50Z")

</div>

```julia
julia> x=dni.==1;
julia> y=id_HH.==uid_HH[1];
julia> length(x)
334189
julia> length(y)
334189
julia> eltype(x)
Bool
julia> eltype(y)
Bool
julia> size(y)
(334189,)
julia> size(x)
(334189,)

```

Now please see on first record of result &

```julia
julia> x&y
334189-element BitArray{1}:
  true
 false
     ?
 false

julia> dni.==1&id_HH.==uid_HH[1]
334189-element BitArray{1}:
 false
 false
     ?
 false

```

Why ? first records:

```julia
julia> dni.==1
334189-element BitArray{1}:
  true
  true
  true
....

julia> id_HH.==uid_HH[1]
334189-element BitArray{1}:
  true
 false
 false
...

```

Paul

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [February 1, 2017, 3:03pm UTC](https://discourse.julialang.org/t/whay-operator-on-two-the-same-bool-vectors-give-others-result/1821/2 "2017-02-01T15:03:22Z")

</div>

Please always quote your code using backticks (`) and provide a minimal example that can be executed, including example data (which can be just 1, 2 etc).

---

<div class="post-metadata">

### Author: ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)
#### Post date: [February 1, 2017, 3:08pm UTC](https://discourse.julialang.org/t/whay-operator-on-two-the-same-bool-vectors-give-others-result/1821/3 "2017-02-01T15:08:47Z")

</div>

Because `&` has higher precedence than `.==`. You need to add parentheses:  
`(dni.==1) & (id_HH.==uid_HH[1])`
