Bitwise AND on integer value

I have a datafield in my collection with a bitmask, and I need to filter on just the values with a certain mask set (bit 22 should be set, or integer 4194304). I can do a BITAND in Excel or Google Sheet, but I am not sure how to do the same in EDT. I see the BIT Calculate operation, but that seems to only validate a boolean against another, not do a AND operation of two integers? Is there a way to do this in EDT?

I found I could do this using the Javascript function:

// Mask is the integer value of the bitmask I want to validate against
const mask = 4194304; // bit 22

return ($(myField) & mask) === mask;

Gives me a true/false flag for filtering. In case anyone else bumps into this. If there is a better solution, I am all ears! :slight_smile:

Calculate supports Boolean AND, OR and XOR.

But there is currently no direct support in Easy Data Transform for bitwise operations such as:

  • bitwise AND
  • bitwise OR
  • bitwise XOR

So you will have to use the Javascript transform.

I think you are the first person to ask for bitwise operations. We might possibly add these to Calculate at some point. I would have to think about bitwise SHIFT and bitwise NOT, because these imply a ‘word’ length, that we don’t currently have in Easy Data Transform.