Free calculatorLive resultsSteps and sourcesEmbed on your site, free

Two Complement Calculator

Two's Complement Calculator works out Result in the target base and Decimal value from Number, Word width and Uppercase digits. The default figures on this page give result in the target base of -101010; change any entry and the result, the working and the sources update together.

Result in the target base
-101010
Number Base Converter and Binary Calculator
Decimal value
-42
Binary
-101010
Octal
-52
Hexadecimal
-2a
Decimal value (numeric)
-42
Bits needed (magnitude)
6
Two's complement pattern
11010110
One's complement pattern
11010101
Unsigned value of that pattern
214
Binary in nibbles
0010 1010
Worked out from Donald E. Knuth, The Art of Computer Programming, Volume 2: Seminumerical Algorithms, section 4.1 (Positional Number Systems) and 2 other sources.

Your figures

Updates as you type
Digits in the "from" base. 0x, 0b and 0o prefixes, spaces and underscores are accepted; a leading minus sign is allowed.
Used for the two's complement pattern and for bitwise operations.

How this is worked out

2 steps
  1. "-42" read in base 10 is -42 in decimal.
  2. -42 in base 2 is -101010.

Its 5 worked examples are re-run on every release, last on 15 September 2026. What changed

Sources and references

3 sources
Donald E. Knuth, The Art of Computer Programming, Volume 2: Seminumerical Algorithms, section 4.1 (Positional Number Systems)
3rd edition, 1997 · Definition of positional notation and of radix conversion by repeated division.
IEEE Std 754 / ISO/IEC 9899 (C) section 6.2.6.2 - integer representations
Two's complement: a negative value n in an N-bit field is stored as 2^N + n.
ECMA-262, ECMAScript Language Specification - BigInt.asUintN / BigInt.asIntN
Defines the modular wrap used here for fixed-width results.

What the Two's Complement Calculator calculates

Converts whole numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36, and performs binary arithmetic and bitwise operations with two's complement fixed-width results.

How to use this Two's Complement Calculator

Enter Number, Word width and Uppercase digits. Result in the target base updates as you type. Change one figure at a time to see what drives the result.

How the result is worked out

Open “How this is worked out” beside the result for the step-by-step calculation behind Result in the target base, Decimal value and Binary.

The method follows Donald E. Knuth, The Art of Computer Programming, Volume 2: Seminumerical Algorithms, section 4.1 (Positional Number Systems), IEEE Std 754 / ISO/IEC 9899 (C) section 6.2.6.2 - integer representations and ECMA-262, ECMAScript Language Specification - BigInt.asUintN / BigInt.asIntN.

What you can compare

Change one input at a time to see how it affects Result in the target base, Decimal value and Binary. The inputs you can vary are Number, Word width and Uppercase digits.

Results are general information, not financial, tax, legal, medical or engineering advice. Check any decision that matters with a qualified professional.

Embed this calculator on your website

Copy this code into any page. The calculator appears with the figures currently entered, sizes itself to fit, and a small credit line links back here. Free, no account, no ads inside it, no tracking of your readers. Set your own figures and fixed fields; Personal removes the credit line, sets your colour and shows you which sites use it.

Preview

See something wrong? Report a problem with this calculator

Frequently asked questions

How to calculate 2nd complement?

Converts whole numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36, and performs binary arithmetic and bitwise operations with two's complement fixed-width results. Open “How this is worked out” beside the result to see each step for your own figures.

What is 11111111 in two's complement?

Converts whole numbers between binary, octal, decimal, hexadecimal and any base from 2 to 36, and performs binary arithmetic and bitwise operations with two's complement fixed-width results. On this page it is computed from Number, Word width and Uppercase digits and shown as Result in the target base, Decimal value and Binary.

What is the 2s complement of 7?

On the figures this page opens with, the result in the target base is -101010. No single number fits everyone: it follows Number, Word width and Uppercase digits, so enter your own above and the answer updates as you type.

What is the 2's complement of 1100?

It needs Number, Word width and Uppercase digits. Nothing else is required, and the figures stay in your browser.

What information do I need for the Two's Complement Calculator?

You need Number, Word width and Uppercase digits. The page opens with default figures that give result in the target base of -101010, so you can see the scale before entering your own.

What does this Two's Complement Calculator show?

It shows Result in the target base, Decimal value, Binary, Octal, Hexadecimal, Decimal value (numeric), Bits needed (magnitude) and Two's complement pattern, with the working and any warnings for your entries.

Related calculators

View all related calculators12 more