# Elementwise comparison of Arrays yield a x-element BitArray{1} with zeros instead of Bool

**URL:** https://discourse.julialang.org/t/elementwise-comparison-of-arrays-yield-a-x-element-bitarray-1-with-zeros-instead-of-bool/28700
**Category:** New to Julia
**Tags:** question
**Created:** [September 12, 2019, 8:16pm UTC](https://discourse.julialang.org/t/elementwise-comparison-of-arrays-yield-a-x-element-bitarray-1-with-zeros-instead-of-bool/28700 "2019-09-12T20:16:19Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![markushhh](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@markushhh](https://discourse.julialang.org/u/markushhh)
#### Post date: [September 12, 2019, 8:16pm UTC](https://discourse.julialang.org/t/elementwise-comparison-of-arrays-yield-a-x-element-bitarray-1-with-zeros-instead-of-bool/28700/1 "2019-09-12T20:16:19Z")

</div>

Is this a known and desirable result?  
I just tested this in in v"1.1.0" and the result is a Bool.  
From the Doc (v1.2): “Note that comparisons such as `==` operate on whole arrays, giving a single boolean answer. Use dot operators like `.==` for elementwise comparisons. (For comparison operations like `<` , _only_ the elementwise `.<` version is applicable to arrays.)”

Julia v"1.2.0"

```
log.([1]) .< 0
> 1-element BitArray{1}:
> 0

log.([1; 1]) .< 0
> 2-element BitArray{1}:
> 0
> 0

log.([1, 1]) .< 0
> 2-element BitArray{1}:
> 0
> 0

[1, 1] .< [2, 2]
> 2-element BitArray{1}
> 1
> 1

```

whereas

```
log.((1, 1)) .< 0
> (false, false)

log.(1) .< 0
> false

```

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [September 13, 2019, 2:58am UTC](https://discourse.julialang.org/t/elementwise-comparison-of-arrays-yield-a-x-element-bitarray-1-with-zeros-instead-of-bool/28700/2 "2019-09-13T02:58:20Z")

</div>

The elements _are_ boolean. In Julia, `Bool` is a subtype of `Number` with `true == 1` and `false == 0`. When you print a whole array of boolean values (e.g. a `BitArray`), the elements simply print as `0` and `1` in Julia 1.2, rather than as `true` and `false`, for legibility and compactness.

```julia
julia> b = BitArray([true, false, true, true, false])
5-element BitArray{1}:
 1
 0
 1
 1
 0

julia> b[2]
false

```

---

<div class="post-metadata">

### Author: ![markushhh](https://avatars.discourse-cdn.com/v4/letter/m/f1d935/32.png) [@markushhh](https://discourse.julialang.org/u/markushhh)
#### Post date: [September 13, 2019, 11:11am UTC](https://discourse.julialang.org/t/elementwise-comparison-of-arrays-yield-a-x-element-bitarray-1-with-zeros-instead-of-bool/28700/3 "2019-09-13T11:11:13Z")

</div>

Nice!  
I couldn’t find anything in the release notes or in the documentary, thanks for that!
