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:

Applications  (1)

Generate a number in which specified bits are set:

Show which bits have been set:

Wolfram Research (2007), BitSet, Wolfram Language function, https://reference.wolfram.com/language/ref/BitSet.html.

Text

Wolfram Research (2007), BitSet, Wolfram Language function, https://reference.wolfram.com/language/ref/BitSet.html.

CMS

Wolfram Language. 2007. "BitSet." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/BitSet.html.

APA

Wolfram Language. (2007). BitSet. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BitSet.html

BibTeX

@misc{reference.wolfram_2024_bitset, author="Wolfram Research", title="{BitSet}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/BitSet.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_bitset, organization={Wolfram Research}, title={BitSet}, year={2007}, url={https://reference.wolfram.com/language/ref/BitSet.html}, note=[Accessed: 22-November-2024 ]}