How can I get bit array segment converted to int?

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?

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.

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