Bit inversion

From Vero - Wikipedia
Revision as of 19:09, 25 August 2025 by imported>Frap (Usage in computing)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Template:Short description

In computing and telecommunications, bit inversion refers to the changing of the state of a bit or binary number to the opposite state, for example changing a 0 bit to 1 or vice versa.<ref>Template:Cite web</ref><ref>Template:Cite web</ref><ref>Template:Cite web</ref> It is often represented with a tilde (~).<ref>Template:Cite web</ref> It also refers to the changing of a state representing a given bit to the opposite state.

Usage in computing

Many popular programming languages implement bit inversion as an operation. For example, in JavaScript, bit inversion is known as a 'bitwise NOT' and is implemented as seen below:

<syntaxhighlight lang="javascript"> var a = 2; var b = ~ a; </syntaxhighlight>

In this example, a is a 32-bit signed integer and in binary would be 00000000000000000000000000000010. Variable Template:Var is the bit inversion of variable Template:Var and equals 11111111111111111111111111111101 (−3 in decimal).

In Python: <syntaxhighlight lang="pycon"> >>> a = 2 >>> b = ~ a >>> b -3 </syntaxhighlight>

References

Template:Reflist

See also

Template:Wiktionary


Template:Telecom-stub