({{, (RefLink[BitNot, paclet:ref/BitNot])[n]
gives the bitwise NOT of the integer n. }})

OpenersNotesSection(Spacer1)Details

Integer mathematical function, suitable for both symbolic and numerical manipulation.

(RefLink[BitNot, paclet:ref/BitNot])[n] turns ones into zeros and vice versa in the binary bit representation of n.

Integers are assumed to be represented in two's complement form, with an unlimited number of digits, so that (RefLink[BitNot, paclet:ref/BitNot])[n] is simply equivalent to -1-n.

(RefLink[BitNot, paclet:ref/BitNot]) automatically threads over lists.

OpenersPrimaryExamplesSection(Spacer1)Examples  (5)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

-1 corresponds to having all bits on:

BitNot[0]

BitNot[7]

OpenersExampleSection1(Spacer1)Generalizations & Extensions  (1)

Basic symbolic simplifications are done automatically:

BitNot[BitNot[x]]

OpenersExampleSection2(Spacer1)Applications  (1)

Make a shifted version of the rule 45 cellular automaton:

ArrayPlot[IntegerDigits[NestList[BitXor[4#,BitOr[2#,BitNot[#]]]&,1,60],2]]

OpenersExampleSection3(Spacer1)Properties & Relations  (1)

Table[BitNot[n],{n,10}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[BitAnd, paclet:ref/BitAnd])  ▪  (RefLink[BitOr, paclet:ref/BitOr])  ▪  (RefLink[BitXor, paclet:ref/BitXor])  ▪  (RefLink[Not, paclet:ref/Not])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Integer and Number Theoretic Functions, paclet:tutorial/IntegerAndNumberTheoreticalFunctions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Number Digits, paclet:guide/NumberDigits])}, {▪(RefLinkPlain[Bitwise Operations, paclet:guide/BitwiseOperations])}})}})