# Read the bits of a int tag

**URL:** <https://forum.inductiveautomation.com/t/read-the-bits-of-a-int-tag/100932>\
**Category:** Ignition\
**Tags:** scripting, ignition81\
**Created:** [January 15, 2025, 4:50pm UTC](https://forum.inductiveautomation.com/t/read-the-bits-of-a-int-tag/100932 "2025-01-15T16:50:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diego\_Mejia](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Diego\_Mejia](https://forum.inductiveautomation.com/u/Diego_Mejia)\
**Post date:** [January 15, 2025, 4:50pm UTC](https://forum.inductiveautomation.com/t/read-the-bits-of-a-int-tag/100932/1 "2025-01-15T16:50:47Z")

</div>

Hi, we have an int tag in our plc called Alarms whose bits are used for individual alarms. is there an option to view or read each of these bits other than creating an individual tag for each bit? I need this because we need to see the alarms in the alarms banner

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 15, 2025, 4:51pm UTC](https://forum.inductiveautomation.com/t/read-the-bits-of-a-int-tag/100932/2 "2025-01-15T16:51:55Z")

</div>

There is a Bit State alarm mode - you could define an alarm on the one tag for each of the significant bits.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [January 15, 2025, 5:41pm UTC](https://forum.inductiveautomation.com/t/read-the-bits-of-a-int-tag/100932/3 "2025-01-15T17:41:24Z")

</div>

Barring Kevin's advice, which seems like probably the best approach.

In an expression there are multiple ways this can be accomplished. Probably the most straight forward is the `getBit()` expression.

```python
getBit({path/to/tag/value},5) //returns the value of the 5th bit in the tag

```

In scripting there are again multiple ways to accomplish this. Here is one.

```python
def getBit(value, bit):
    return (value & (1 << bit)) >> bit

```

---

<div class="post-metadata">

**Author:** ![Diego\_Mejia](https://avatars.discourse-cdn.com/v4/letter/d/e56c9b/32.png) [@Diego\_Mejia](https://forum.inductiveautomation.com/u/Diego_Mejia)\
**Post date:** [January 15, 2025, 5:43pm UTC](https://forum.inductiveautomation.com/t/read-the-bits-of-a-int-tag/100932/4 "2025-01-15T17:43:22Z")

</div>

thank you so much
