Bit inversion
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.[1][2][3] It is often represented with a tilde (~).[4] 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:
var a = 2;
var b = ~ a;
In this example, a is a 32-bit signed integer and in binary would be 00000000000000000000000000000010. Variable b is the bit inversion of variable a and equals 11111111111111111111111111111101 (−3 in decimal).
In Python:
>>> a = 2
>>> b = ~ a
>>> b
-3
References
- ^ "Bitwise NOT (~) - JavaScript | MDN". developer.mozilla.org. 2023-08-15. Retrieved 2023-10-17.
- ^ "%BITNOT (Invert Bits)". www.ibm.com. 2023-04-11. Retrieved 2023-10-17.
- ^ "Invert actual bits of a number". GeeksforGeeks. 2018-05-18. Retrieved 2023-10-17.
- ^ "~ - Arduino Reference". www.arduino.cc. Retrieved 2023-10-17.
See also
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.