# How can I get the value of a specific bit in the boolean representation of a int

**URL:** <https://forum.inductiveautomation.com/t/how-can-i-get-the-value-of-a-specific-bit-in-the-boolean-representation-of-a-int/71974>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 3, 2023, 2:45pm UTC](https://forum.inductiveautomation.com/t/how-can-i-get-the-value-of-a-specific-bit-in-the-boolean-representation-of-a-int/71974 "2023-04-03T14:45:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gabriel\_Schwinghamme](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@Gabriel\_Schwinghamme](https://forum.inductiveautomation.com/u/Gabriel_Schwinghamme)\
**Post date:** [April 3, 2023, 2:45pm UTC](https://forum.inductiveautomation.com/t/how-can-i-get-the-value-of-a-specific-bit-in-the-boolean-representation-of-a-int/71974/1 "2023-04-03T14:45:40Z")

</div>

I need to has a device react to the 15th bit in the binary representation of a int.  
This is what I see in Studio 5000  
 ![Screenshot 2023-04-03 094205](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/8/680332f4bac1365739fb46612740a93a22f11a14.png)

Here is what I see in ignition

 ![Screenshot 2023-04-03 094300](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/4/e45d29d840e3ddc71b4ea7fde80096fedd9bec9a.png)

This might be something simple. If so sorry I am new.

---

<div class="post-metadata">

**Author:** ![msteele](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/msteele/32/77889_2.png) [@msteele](https://forum.inductiveautomation.com/u/msteele)\
**Post date:** [April 3, 2023, 2:52pm UTC](https://forum.inductiveautomation.com/t/how-can-i-get-the-value-of-a-specific-bit-in-the-boolean-representation-of-a-int/71974/2 "2023-04-03T14:52:00Z")

</div>

The [getBit expression function](https://docs.inductiveautomation.com/display/DOC81/getBit) is your friend for bitpacked booleans.

First, pull in your primary tag as an integer. Then create expression tags to pull out individual bits into booleans.

Here's an example I have for a device with lots of bit packed alarms, the `{path}` is to an integer tag (we call these alarm groups) and then the individual alarms with meaningful names are created with `getBit`.

`getBit({[.]../Alarm Groups/Group 2},5)`

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 3, 2023, 3:09pm UTC](https://forum.inductiveautomation.com/t/how-can-i-get-the-value-of-a-specific-bit-in-the-boolean-representation-of-a-int/71974/3 "2023-04-03T15:09:32Z")

</div>

For the logix driver, simply make an OPC tag with addressing to the bit level. Put the item path you see in the Studio 5000 tag monitor directly into an Ignition OPC item path in an OPC tag, after the bracketed device name. Like so: `[SomeDevice]FV5003_HOA.HOA.HMIbits[0].15`

BTW: That looks like a common PlantPax AOI. You should be aware of the performance issues you may encounter with those:

> [@Automation Professionals' EtherNet/IP Communication Suite V2](https://forum.inductiveautomation.com/t/automation-professionals-ethernet-ip-communication-suite-v2/68190):
>
> Automation Professionals is pleased to announce its latest EtherNet/IP Communications Suite driver module, a major upgrade to its EtherNet/IP Class1 Communications module, as a Public Beta. As of April 15, 2023, this is now a Production Release. The primary new feature is its new Generic EtherNet/IP Client Driver, a drop-in replacement for IA's Logix V21+ driver and its Omron NJ/NX driver. It does work with older Logix processors, and also works with Rockwell's MicroLogix 8xx family (ethernet…

{ /shameless plug }

---

<div class="post-metadata">

**Author:** ![Gabriel\_Schwinghamme](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@Gabriel\_Schwinghamme](https://forum.inductiveautomation.com/u/Gabriel_Schwinghamme)\
**Post date:** [April 3, 2023, 4:33pm UTC](https://forum.inductiveautomation.com/t/how-can-i-get-the-value-of-a-specific-bit-in-the-boolean-representation-of-a-int/71974/4 "2023-04-03T16:33:55Z")

</div>

So in my example would I do getBit({[Testing]_PPD_/Controller:Global/FV5003\_HOA/HOA/HMIbits/HMIbits\_0\_}, 15)?

---

<div class="post-metadata">

**Author:** ![msteele](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/msteele/32/77889_2.png) [@msteele](https://forum.inductiveautomation.com/u/msteele)\
**Post date:** [April 3, 2023, 4:48pm UTC](https://forum.inductiveautomation.com/t/how-can-i-get-the-value-of-a-specific-bit-in-the-boolean-representation-of-a-int/71974/5 "2023-04-03T16:48:21Z")

</div>

If you have access to the device via OPC UA and the tag is a tree like @pturmel suggests, then your best bet is to address items in the tree directly via OPC UA.

e.g.`{[Testing]*PPD* /Controller:Global/FV5003_HOA/HOA/HMIbits/HMIbits_0_.15` for the 15th bit, and make sure the tag data type is boolean.

`getBit()` is more for cases where you only have access to the bitpacked integer and can't address the bit directly in OPC UA.

---

<div class="post-metadata">

**Author:** ![Gabriel\_Schwinghamme](https://avatars.discourse-cdn.com/v4/letter/g/8c91f0/32.png) [@Gabriel\_Schwinghamme](https://forum.inductiveautomation.com/u/Gabriel_Schwinghamme)\
**Post date:** [April 3, 2023, 6:10pm UTC](https://forum.inductiveautomation.com/t/how-can-i-get-the-value-of-a-specific-bit-in-the-boolean-representation-of-a-int/71974/6 "2023-04-03T18:10:34Z")

</div>

Could you give me some steps to do that? are you saying to create a new tag?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 3, 2023, 6:18pm UTC](https://forum.inductiveautomation.com/t/how-can-i-get-the-value-of-a-specific-bit-in-the-boolean-representation-of-a-int/71974/7 "2023-04-03T18:18:22Z")

</div>

> [@Gabriel\_Schwinghamme](#):
>
> are you saying to create a new tag?

Yes.

Ignition's OPC drivers are smart enough to use the request for an integer to satisfy requests for its bits without extra traffic, as long as they are at the same poll rate. The separate tag also provides a path for writing the bit, if that becomes necessary.
