Two’s complement and negative numbers

The two’s complement of an N-bit number is defined as its complement with respect to 2N. For instance, for the three-bit number 010, the two’s complement is 110, because 010 + 110 = 1000. The two’s complement is calculated by inverting the digits and adding one.

Two’s complement is the most common method of representing signed integers on computers, and more generally, fixed point binary values. The two’s complement is a method for representing positive and negative integer values in binary. The useful part of two’s complement is that it automatically includes the sign bit.

The next example shows how use Two’s complement



Systems Engineer with a huge experience working on IT infrastructure projects and passionate about software development, AR/VR, Big Data, and Machine Learning.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store