| layout | title | parent | grand_parent |
|---|---|---|---|
default |
bitwise.and |
Bitwise Functions |
FLEX Function Reference |
Performs a bitwise AND operation on two integers. Each bit in the result is 1 only if the corresponding bits in both operands are 1.
flex.bitwise.and(a, b)| Parameter | Type | Required | Description |
|---|---|---|---|
a |
number (integer) | Yes | First operand |
b |
number (integer) | Yes | Second operand |
Type: number (integer)
The result of the bitwise AND operation.
RETURN flex.bitwise.and(12, 10) AS resultOutput:
result
------
8
(Binary: 1100 AND 1010 = 1000 = 8)
WITH 7 AS userPermissions // 0111 (read=1, write=2, execute=4)
WITH userPermissions, 2 AS writeFlag
RETURN flex.bitwise.and(userPermissions, writeFlag) > 0 AS hasWriteMATCH (d:Device)
WITH d, flex.bitwise.and(d.flags, 15) AS lowerNibble
RETURN d.id, lowerNibble- Operates on 32-bit signed integers in JavaScript
- Both operands are converted to integers if needed
- Commonly used for flag checking and bit masking
- bitwise.or - Bitwise OR operation
- bitwise.xor - Bitwise XOR operation
- bitwise.not - Bitwise NOT operation