BitFlip[n,k]
flips the bit corresponding to the coefficient of
in the integer n.
BitFlip
BitFlip[n,k]
flips the bit corresponding to the coefficient of
in the integer n.
Details
Examples
open all close allBasic Examples (1)
Flip the initial bit of the number 2 from a 0 to a 1:
BitFlip[2, 0]Flip the second digit of 13, counting from the right:
BitFlip[13, 1]Flip the second digit of 13, counting form the left:
BitFlip[13, -2]Starting with the number 0, flip positional bits:
Table[BitFlip[0, i], {i, 0, 7}]Scope (2)
Digits beyond the highest set bit are implicitly set to 0:
BitLength[13]IntegerDigits[13, 2]BitFlip[13, 4]IntegerDigits[%, 2]If a flip position is given to the right of the initial set bit, the original value will be unchanged:
BitFlip[3, -3]Properties & Relations (2)
See Also
Related Guides
History
Text
Wolfram Research (2024), BitFlip, Wolfram Language function, https://reference.wolfram.com/language/ref/BitFlip.html.
CMS
Wolfram Language. 2024. "BitFlip." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/BitFlip.html.
APA
Wolfram Language. (2024). BitFlip. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BitFlip.html
BibTeX
@misc{reference.wolfram_2026_bitflip, author="Wolfram Research", title="{BitFlip}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/BitFlip.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_bitflip, organization={Wolfram Research}, title={BitFlip}, year={2024}, url={https://reference.wolfram.com/language/ref/BitFlip.html}, note=[Accessed: 13-June-2026]}