# \`Vector{Bool}\` to Int

**URL:** <https://discourse.julialang.org/t/vector-bool-to-int/89560>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 31, 2022, 1:21pm UTC](https://discourse.julialang.org/t/vector-bool-to-int/89560 "2022-10-31T13:21:05Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [November 1, 2022, 5:01pm UTC](https://discourse.julialang.org/t/vector-bool-to-int/89560/12 "2022-11-01T17:01:40Z")

</div>

The base for loop performs even better if it specializes in the specific case of base 2 numbers

```julia
julia> function poly_2_eval(p)
           ex = 0
           for e in p
               ex *= 2
               ex+=e
           end
           ex
       end
poly_2_eval (generic function with 1 method)

julia> @btime poly_2_eval(v)
  15.030 ns (0 allocations: 0 bytes)
221

```

---

_[View the full topic](https://discourse.julialang.org/t/vector-bool-to-int/89560)._
