# BitFlip

BitFlip[n,k]

flips the bit corresponding to the coefficient of in the integer n.

# Details

• BitFlip changes an individual bit in an integer(from 0 to 1 and 1 to 0).
• The lowest bit of integer n (e.g. signifying ) is flipped with k=0.
• BitFlip[n,k] changes the bit k places from the right. For negative k specifications, the position is counted from the left, beginning with the final set bit.

# Examples

open allclose all

## Basic Examples(1)

Flip the initial bit of the number 2 from a 0 to a 1:

Flip the second digit of 13, counting from the right:

Flip the second digit of 13, counting form the left:

Starting with the number 0, flip positional bits:

## Scope(2)

Digits beyond the highest set bit are implicitly set to 0:

If a flip position is given to the right of the initial set bit, the original value will be unchanged:

## Properties & Relations(2)

For digits that are set to 1, BitFlip is equivalent to BitClear:

For digits that are set to 0, BitFlip is equivalent to BitSet:

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

#### 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_2024_bitflip, author="Wolfram Research", title="{BitFlip}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/BitFlip.html}", note=[Accessed: 15-August-2024 ]}

#### BibLaTeX

@online{reference.wolfram_2024_bitflip, organization={Wolfram Research}, title={BitFlip}, year={2024}, url={https://reference.wolfram.com/language/ref/BitFlip.html}, note=[Accessed: 15-August-2024 ]}