This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

BitSet

BitSet
sets to 1 the bit corresponding to the coefficient of in the integer n.
  • BitSet sets the bit k places from the right.
Display coefficients at powers of 2 in the integer 42:
Set the bit corresponding to the coefficient at to 1:
Set the bit corresponding to the coefficient at :
Display coefficients at powers of 2 in the integer 42:
In[1]:=
Click for copyable input
Out[1]=
Set the bit corresponding to the coefficient at to 1:
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
Set the bit corresponding to the coefficient at :
In[4]:=
Click for copyable input
Out[4]=
In[5]:=
Click for copyable input
Out[5]=
BitSet automatically creates an integer of the necessary size:
New in 6