Binary is a base-2 number system that uses two states 0 and 1 to represent a number. We can also call it to be a true state and a false state. A binary number is built the same way as we build the normal decimal number.

For example, a decimal number 45 can be represented as 4*10^1+5*10^0 = 40+5

Now in binary 45 is represented as 101101. As we have powers of 10 in decimal number similarly there are powers of 2 in binary numbers. Hence 45 which is 101101 in binary can be represented as:

2^0*1+2^1*0+2^2*1+2^3*1+2^4*0+2^5*1 = 45

The binary number is traversed from left to right.

**Sign and Magnitude representation –**

There are many ways for representing negative integers. One of the way is sign-magnitude. This system uses one bit to indicate the sign. Mathematical numbers are generally made up of a sign and a value. The sign indicates whether the number is positive, (+) or negative, (–) while the value indicates the size of the number.

For example 13, +256 or -574. Presenting numbers is this way is called sign-magnitude representation since the left most digit can be used to indicate the sign and the remaining digits the magnitude or value of the number.

Sign-magnitude notation is the simplest and one of the most common methods of representing positive and negative numbers. Thus negative numbers are obtained simply by changing the sign of the corresponding positive number, for example, +2 and -2, +10 and -10, etc. Similarly adding a 1 to the front of a binary number is negative and a 0 makes it positive.

For example 0101101 represents +45 and 1101101 represents -45 if 6 digits of a binary number are considered and the leftmost digit represents the sign.

But a problem with the sign-magnitude method is that it can result in the possibility of two different bit patterns having the same binary value. For example, +0 and -0 would be 0000 and 1000 respectively as a signed 4-bit binary number. So using this method there can be two representations for zero, a positive zero 0000 and also a negative zero 1000 which can cause big complications for computers and digital systems.

The 2 *compliment* notations used to represent signed magnitude numbers are:

**One’s compliment –**

One’s Complement is a method which can be used to represent negative binary numbers in a signed binary number system. In one’s complement, positive numbers remain unchanged as before.Negative numbers however, are represented by taking the one’s complement of the unsigned positive number. Since positive numbers always start with a 0, the complement will always start with a 1 to indicate a negative number.

The one’s complement of a negative binary number is the complement of its positive, so to take the one’s complement of a binary number, all we need to do is subtract 1’s equal to the number of digits present in the number from that number. This can also be achieved by just interchanging the digits of the number. Thus the one’s complement of 1 is 0 and vice versa.

For example One’s Compliment of 1010100:

1111111 -1010100 0101011

*The one’s compliment of number can also be obtained by just interchanging the digits of the binary number*.**Two’s compliment –**

Two’s Complement is another method like one’s complement form, which we can use to represent negative binary numbers in a signed binary number system. In two’s complement, the positive numbers are exactly the same as before for unsigned binary numbers. A negative number, however, is represented by a binary number, which when added to its corresponding positive equivalent results in zero.

In two’s complement representation, a negative number is the 2’s complement of its positive number. If the subtraction of two numbers is X – Y then it can be represented as X + (2’s complement of Y).

*The two’s complement is one’s complement + 1 of a number in binary*.The main

**advantage**of two’s complement over the previous one’s complement is that there is no double-zero problem and it is a lot easier to generate the two’s complement of a signed binary number. In two’s compliment arithmetic operations are relatively easier to perform when the numbers are represented in the two’s complement format.For example to represent -27

27 in binary is: 0001101111111111 -00011011 11100100 <-- 1's Compliment +1 11100101 <-- The 2's Compliment

The above 2 are the formats that can be too long practically. So real number representations are used.

**Real number representations –**

The goal is to represent a number with a decimal point in binary using the form. IEEE 754 standard defines how to encode a real number. This standard offers a way to code a number using 32 bits (as well as 64 bits), and defines three components:

- The plus/minus sign is represented by one bit, the highest-weighted bit (furthest to the left).
- The exponent is encoded using 8 bits (11 bits in 64 bit representation) immediately after the sign.
- The mantissa (the bits after the decimal point) with the remaining 23 bits(52 bits in 64 bit representation).

## Recommended Posts:

- Digital logic | Binary Decoder
- Digital logic | Code Converters - Binary to/from Gray Code
- Digital Logic | Logic Gates
- Digital logic | Encoder
- Digital Logic | 5 variable K-Map
- Digital Logic | Latches
- Digital Logic | Implicants in K-Map
- Counters in Digital Logic
- Digital logic | Ripple Counter
- Digital Logic | Full Subtractor
- Digital Logic | Consensus theorem
- Digital logic | Magnitude Comparator
- Digital logic | Encoders and Decoders
- Digital logic | Variable entrant map (VEM)
- Digital logic | Functional Completeness

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.