# Covert BitArray to Int64

**URL:** <https://discourse.julialang.org/t/covert-bitarray-to-int64/9193>\
**Category:** General Usage\
**Created:** [February 20, 2018, 5:38am UTC](https://discourse.julialang.org/t/covert-bitarray-to-int64/9193 "2018-02-20T05:38:20Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [February 20, 2018, 2:25pm UTC](https://discourse.julialang.org/t/covert-bitarray-to-int64/9193/5 "2018-02-20T14:25:00Z")

</div>

It might be even easier to just build your own array type that just uses the `Int` directly as its storage:

```julia
julia> mutable struct IntBitVec <: AbstractVector{Bool}
           data::UInt64
       end
       Base.size(::IntBitVec) = (64,)
       @inline function Base.getindex(v::IntBitVec, i::Int)
           @boundscheck checkbounds(v, i)
           v.data & (1 << (i-1)) != 0 # Just change i-1 to 65-i to reverse the bits
       end

julia> IntBitVec(1)
64-element IntBitVec:
  true
 false
 false
 false
     ⋮

julia> IntBitVec(2)
64-element IntBitVec:
 false
  true
 false
 false
     ⋮

```

---

_[View the full topic](https://discourse.julialang.org/t/covert-bitarray-to-int64/9193)._
