BitSet

BitSet[n,k]

sets to 1 the bit corresponding to the coefficient of in the integer n.

Details

  • BitSet[n,k] sets the bit k places from the right.

Examples

open allclose all

Basic Examples  (1)

Display coefficients at powers of 2 in the integer 42:

Set the bit corresponding to the coefficient at 20 to 1:

Set the bit corresponding to the coefficient at 24:

Scope  (1)

BitSet automatically creates an integer of the necessary size:

Introduced in 2007
 (6.0)