Tool for quickly calculating the 1's complement and 2's complement of binary numbers for their use in computer arithmetic.
Binary Complement - dCode
Tag(s) : Arithmetics
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
In informatics, one's complement (bit flip) is writing a number inversing 0 and 1.
Example: Ones complement of 0111 becomes 1000
2's complement is a binary operation obtained by making a 1's complement (reversing all the bits of a number) and then adding 1 to the result (ignoring potential overflow).
Example: The two's complement of the number 5 (in binary 0101) is 1011
The 2's complement of a stored zero number (composed of zeros) 0 (or 00000000) is itself (i.e. 0).
The 2's complement operation will set all the bits to 1, then adding 1 will result in all the bits being reset to 0 (because the overflow is ignored).
The complement of a number is a very easy and quick number to calculate (mostly bit inversions) and which has several interesting properties compared to the original number.
In computing, signed integer storage uses complements to calculate the opposite of a number (negative/positive).
2's complement is even created to facilitate addition/subtraction type calculations.
dCode retains ownership of the "Binary Complement" source code. Any algorithm for the "Binary Complement" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Binary Complement" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Binary Complement" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Binary Complement" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Binary Complement on dCode.fr [online website], retrieved on 2025-04-16,