Alteryx Designer Desktop Knowledge Base

Definitive answers from Designer Desktop experts.

Binary Operations

CristonS
Alteryx Alumni (Retired)
Created

Binary (bit level or bitwise) operations operate on one or more bit patterns or binary numerals at the level of their discrete bits. They are typically used to manipulate values for comparisons and calculations - and encryption!

 

 

These functions are in Formula Tool, in the Integer submenu of the Math menu:

 

 

formula tool.JPG

 

Binary values are stored as strings, retaining the leading zeros. To use these functions, you'll have to convert these to numerals. Use the BinToInt() function to convert your binary strings to numeric values. Once you've completed your calculations, use IntToBin() to get the binary values. Note: you'll need to add your leading zeros back in, using the PadLeft function.

 

 

E.g.: PadLeft(IntToBin([converted_binary]),8,'0')

 

 

If you need the character associated with the binary value, use CharToInt(). Hex calculations work similarly.

 

 

formula tool2.JPG

 

BinaryAnd(n,m) – performs the logical AND operation on two binary numerals

 

 

BinaryNot(n) – performs logical negation, forming the complement (bits that are 0 become 1, and those that are 1 become 0)

 

 

BinaryXOr(n,m) - exclusive disjunction essentially means 'either one, but not both nor none'. In other words, the statement is true if and only if one is true and the other is false.

 

 

A common use for XOR is a means of doing a parity check. A bitstring has even parity if the number of 1s in the string is even. It has an odd parity if the number of 1s is odd. If you XOR the bits together, you can tell whether a bitstring has even or odd parity.

 

 

ShiftLeft(n,b) / ShiftRight(n,b) - shifting left is equivalent to multiplication by powers of 2. So 5 << 1 is equivalent to 5 * 2, and 5 << 3 is equivalent to 5 * 8. Shifting to the right is equivalent to division by powers of 2.

 

 

Please see the attached v10.5 workflow for a simple secret message conversion.

 

 

Happy Alteryx-ing!

Attachments
Comments
jrobiso2
8 - Asteroid

Given the following date:

Binary Mask                                       Binary IP                                                  BinaryAND Result
11111111111111111111111110000000 00010011100000111000000000000000 10011100000111000000000000000
11111111111111111111111110000000 00010011100000111000000010000000 10011100000111000000010000000
11111111111111111111111110000000 00010011100000111000000100000000 10011100000111000000100000000
11111111111111111111111110000000 00010011100000111000000110000000 10011100000111000000110000000
11111111111111111111111111000000 00010011100000111000001010000000 10011100000111000001010000000
11111111111111111111111111000000 00010011100000111000001011000000 10011100000111000001011000000
11111111111111111111111111110000 00010011100000111000001110110000 10011100000111000001110110000
 
This looks more like a BinaryOR than an AND result.
 
I'm using the following formula:
 
IntToBin(BinaryAnd(BinToInt([BinaryIPAddress]),BinToInt([BinaryMask])))