# How can I get bit array segment converted to int?

**URL:** <https://forums.unrealengine.com/t/how-can-i-get-bit-array-segment-converted-to-int/342283>\
**Category:** Community & Industry Discussion\
**Tags:** math, conversion, unreal-engine, Array, question\
**Created:** [December 23, 2015, 5:08pm UTC](https://forums.unrealengine.com/t/how-can-i-get-bit-array-segment-converted-to-int/342283 "2015-12-23T17:08:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thumper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Thumper](https://forums.unrealengine.com/u/Thumper)\
**Post date:** [December 23, 2015, 5:08pm UTC](https://forums.unrealengine.com/t/how-can-i-get-bit-array-segment-converted-to-int/342283/1 "2015-12-23T17:08:26Z")

</div>

I’m using a bit array to store some states of a triangle. Basically the left bottom vertex is the first bit, top middle is second, and bottom right is third. Right now this is fine but I have plans to have a second set of bits that determine a height offset. I’ll likely just jumble them in with the first set of bits and only grab the bit portion I need to convert to a number. Anyhow, is there a way to convert bits directly to their represented number? For instance, 101 in bits should be 5?

---

<div class="post-metadata">

**Author:** ![Thumper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Thumper](https://forums.unrealengine.com/u/Thumper)\
**Post date:** [December 23, 2015, 5:53pm UTC](https://forums.unrealengine.com/t/how-can-i-get-bit-array-segment-converted-to-int/342283/2 "2015-12-23T17:53:19Z")

</div>

In fact, how do I initialize a TBitArray? TBitArray ? I see in the documentation that it has a minimal initializer TBitArray( bool, int) but I’m confused about how to assign this a name.

---

<div class="post-metadata">

**Author:** ![Thumper](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Thumper](https://forums.unrealengine.com/u/Thumper)\
**Post date:** [December 23, 2015, 6:06pm UTC](https://forums.unrealengine.com/t/how-can-i-get-bit-array-segment-converted-to-int/342283/3 "2015-12-23T18:06:22Z")

</div>

TBitArray aBitArray seams to work. Now I just need to figure out how to convert to number.
