Two’s Complement Calculator
Two’s complement negates by inverting the bits and adding 1: −45 in 8 bits is 1101 0011.
1101 0011
- One’s complement
- 1101 0010
- Sign-magnitude
- 1010 1101
- Hex (two’s complement)
- 0xD3
- Range of 8-bit two’s complement
- -128 to 127
Step-by-step solution
- |-45| in binary = 00101101
- Invert the bits: 11010010
- Add 1: 11010011
Two’s Complement Formula
−x = invert(x) + 1
n-bit range −2ⁿ⁻¹ … 2ⁿ⁻¹ − 1
Worked Example
−45 as an 8-bit number:
- |-45| in binary = 00101101
- Invert the bits: 11010010
- Add 1: 11010011
Sign-magnitude: 1010 1101 · Hex (two’s complement): 0xD3 · Range of 8-bit two’s complement: -128 to 127
GATE tip
Sign extension copies the sign bit: 8-bit 1101 0011 becomes 16-bit 1111 1111 1101 0011 with the same value −45. GATE often tests this with hex like 0xD3 → 0xFFD3.
More Digital Logic and Number Representation Calculators
-
Number Base Converter
N = Σ dᵢ·bⁱ
integer part: repeated division; fraction: repeated multiplication by the base
Example: The decimal number 45.625: Binary = 101101.101.
-
IEEE 754 Floating Point Converter
value = (−1)ˢ × 1.m × 2^(e − bias)
single: 8-bit exponent, bias 127, 23-bit mantissa; double: 11, 1023, 52
Example: −12.375 in single precision: IEEE 754 single (hex) = 0xC1460000.
-
K-Map Solver
F = Σm(…) + d(…) → minimal SOP / POS
Quine–McCluskey with an exact minimum cover
Example: F(A, B, C, D) = Σm(0, 1, 2, 5, 6, 7, 8, 9, 10, 14): Minimal SOP: F(A, B, C, D) = B′C′ + CD′ + A′BD.
Frequently asked questions
Why is two’s complement used instead of sign-magnitude?
It has a single zero and the same adder works for signed and unsigned numbers, so subtraction is just addition of the complement.
How do I detect overflow in two’s complement addition?
Overflow occurs when two numbers of the same sign give a result of the other sign, i.e. when the carry into and out of the sign bit differ.
Sources
Last reviewed: . Factors are stored exactly and computed with 50-digit decimal arithmetic. See how we verify conversion factors.
Cite this page
APA
Scientific Converters. (2026, October 15). Two’s Complement Calculator. Retrieved October 25, 2026, from https://scientificconverters.com/calculators/twos-complement-calculator/
IEEE
Scientific Converters, "Two’s Complement Calculator," scientificconverters.com. Accessed: Oct. 25, 2026. [Online]. Available: https://scientificconverters.com/calculators/twos-complement-calculator/