Wolfram Research

Function Repository Resource:

BitBooleanFunction

Source Notebook

Apply a Boolean function to corresponding bits in integers

Contributed by: Stephen Wolfram

ResourceFunction["BitBooleanFunction"][k][x,y]

computes the kth bitwise Boolean function of the integers x and y.

ResourceFunction["BitBooleanFunction"][k,n][x1,,xn]

computes the kth n-input bitwise Boolean function of the integers xi.

Details and Options

BitBooleanFunction is a generalization of BitAnd, BitXor, etc.

Examples

Basic Examples

Compute the 6th bitwise Boolean function:

In[1]:=
ResourceFunction["BitBooleanFunction"][6][123, 456]
Out[1]=
In[2]:=
ResourceFunction["BitBooleanFunction"][150, 3][123, 456, 789]
Out[2]=

Properties and Relations

In[3]:=
ResourceFunction["BitBooleanFunction"][6][123, 456]
Out[3]=

This corresponds to computing a bitwise XOR:

In[4]:=
BitXor[123, 456]
Out[4]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Resource History

License Information