# Node-red-contrib-remote-io, digital output for joining bool to word

**URL:** <https://discourse.nodered.org/t/node-red-contrib-remote-io-digital-output-for-joining-bool-to-word/11798>\
**Category:** General\
**Created:** [3 June 2019 13:33 UTC](https://discourse.nodered.org/t/node-red-contrib-remote-io-digital-output-for-joining-bool-to-word/11798 "2019-06-03T13:33:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [3 June 2019 16:07 UTC](https://discourse.nodered.org/t/node-red-contrib-remote-io-digital-output-for-joining-bool-to-word/11798/2 "2019-06-03T16:07:20Z")

</div>

If you mean combining bits to make a WORD value - its just basic math functionality of the programming language.

e.g....

```auto
//Get bit
function getBit(number, bitPosition) {
  return (number & (1 << bitPosition)) === 0 ? 0 : 1;
}

//Set Bit
function setBit(number, bitPosition) {
  return number | (1 << bitPosition);
}

//Clear Bit
function clearBit(number, bitPosition) {
  const mask = ~(1 << bitPosition);
  return number & mask;
}

//Update Bit
function updateBit(number, bitPosition, bitValue) {
  const bitValueNormalized = bitValue ? 1 : 0;
  const clearMask = ~(1 << bitPosition);
  return (number & clearMask) | (bitValueNormalized << bitPosition);
}

```

You could use the code from these to update a WORD value and set / reset bits...

```auto
var plcValue = msg.payload;

//Set Bit 12
plcValue = plcValue | (1 << 12);

//reset Bit 3
const mask = ~(1 << 3);
plcValue = plcValue & mask;

msg.payload = plcValue; //(return this for next node to send it back to the PLC

```

Hope that helps.

---

_[View the full topic](https://discourse.nodered.org/t/node-red-contrib-remote-io-digital-output-for-joining-bool-to-word/11798)._
