How it’s calculated
Binary uses only the digits 0 and 1, and each place is worth twice the one to its right (1, 2, 4, 8, 16, …). Arithmetic works like decimal arithmetic, but you carry as soon as a column reaches 2. Octal (base 8) and hexadecimal (base 16) are shorthand for binary: each octal digit stands for 3 bits and each hex digit for 4 bits.
Example: 1011 + 110. In decimal that is 11 + 6. Column by column from the right: 1 + 0 = 1; 1 + 1 = 10 (write 0, carry 1); 0 + 1 + carry 1 = 10 (write 0, carry 1); 1 + carry 1 = 10. Reading the result: 10001, which is 17 in decimal, 11 in hex. A bitwise example: 00001100 AND 00001010 = 00001000 (12 AND 10 = 8), because only the 8s bit is set in both.
Bitwise operations and bit width. The bitwise operations act on a fixed number of bits (8, 16, 32 or 64). Negative numbers are stored in two's complement: invert the bits of the positive number and add 1, so −1 at 8 bits is 11111111. NOT of 00001100 (12) at 8 bits is 11110011, which is 243 unsigned or −13 signed. A logical shift fills with zeros; an arithmetic shift right copies the sign bit so negative numbers stay negative.
To simply convert one number between bases (with no arithmetic), use the number base converter.
Frequently asked questions
How do I add binary numbers?
Add column by column from the right, just as in decimal, but 1 + 1 = 10 in binary, so write 0 and carry 1 to the next column. For example 1011 + 110 = 10001.
What is the difference between >> and >>>?
Both shift bits to the right. >>> (logical) always fills the left end with 0s. >> (arithmetic) copies the sign bit, so negative numbers stay negative. For positive numbers they give the same answer.
Why do I get a large number when I use NOT?
NOT flips every bit at the chosen width, so NOT 0 at 8 bits is 11111111 = 255 unsigned. As a signed number the same bits mean −1, which is shown under "signed".
Does subtraction give negative binary numbers?
For ordinary arithmetic the answer is shown with a minus sign (1 − 11 = −10). The bit patterns of two's complement are used only for the bitwise operations, where the width matters.
Embed this calculator
Add this free calculator to your own website. Copy the code below into your page’s HTML:
Need this calculator branded, changed or built around your own prices?See custom business solutions →
Sources
- Binary, Octal, and Hexadecimal (Introduction to College Mathematics) — LibreTexts Mathematics (Lumen Learning)
- Dive Into Systems, §4.6 Bitwise Operators (AND, OR, XOR, NOT, left shift, logical and arithmetic right shift) — Dive Into Systems (Matthews, Newhall & Webb; West Point and Swarthmore College), free online textbook
- Dive Into Systems, §4.3 Signed Binary Integers (two's complement: flip all the bits and add one) — Dive Into Systems (Matthews, Newhall & Webb; West Point and Swarthmore College), free online textbook
- Dive Into Systems, §4.4.1 Addition (binary addition with carries) — Dive Into Systems (Matthews, Newhall & Webb; West Point and Swarthmore College), free online textbook
- Converting to Different Base Systems — LibreTexts Mathematics (Florida SouthWestern State College)
Formulas are taken from the free public references above. Results are provided “as is” for informational and educational purposes only. See our disclaimer.
Added · Last updated · How we check our calculators
Spotted a mistake or missing option? Report a problem· Suggest a calculator