# Troubles making a Derived Boolean Tag work as a mask for a Short Tag

**URL:** <https://forum.inductiveautomation.com/t/troubles-making-a-derived-boolean-tag-work-as-a-mask-for-a-short-tag/15203>\
**Category:** Ignition\
**Created:** [August 30, 2017, 4:28pm UTC](https://forum.inductiveautomation.com/t/troubles-making-a-derived-boolean-tag-work-as-a-mask-for-a-short-tag/15203 "2017-08-30T16:28:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [August 30, 2017, 4:57pm UTC](https://forum.inductiveautomation.com/t/troubles-making-a-derived-boolean-tag-work-as-a-mask-for-a-short-tag/15203/2 "2017-08-30T16:57:38Z")

</div>

I’ve made it work using the following expressions:

Read:

```auto
(toInt({source}) >> N) & 1

```

Write:

```auto
if({value}, 
	toInt({source}) | (1 << N), 
	toInt({source}) & ~(1 << N))

```

Where N will vary based on the bit number (0-15 for a Modbus register).

You should also turn on the “OPC Optimistic Writes” flag for the scan class these tags belong to or you’re going to have a race condition if you try to write to multiple bits in the same word too quickly.

---

_[View the full topic](https://forum.inductiveautomation.com/t/troubles-making-a-derived-boolean-tag-work-as-a-mask-for-a-short-tag/15203)._
