# Learn.Digilentinc | Negative Binary Numbers

Negative Binary Numbers Signed Magnitude and 2's Compliment

Digital systems have a fixed number of signals that can be used to represent binary numbers. Smaller, simpler systems might use 8-bit buses that can only represent 256 different binary numbers, while larger systems might use 16, 32, or even 64 bit buses. Whatever the number of bits, all systems have a finite number of wires, storage elements, and processing elements to represent and manipulate digital data. The number of available bits determines how many different numbers can be represented in a given system. Digital circuits that perform arithmetic functions often must deal with negative numbers, so a method of representing negative numbers must be defined. An N-bit system can represent 2^N total numbers, so a useful encoding would use half the available codes (i.e., 2^N/2) to represent positive numbers, and half negative numbers. A single bit can be designated as a “sign bit” to distinguish positive and negative numbers—if the sign bit is '1', the number is negative; if the sign bit is '0', positive. The most-significant-bit (MSB) is a good choice for the sign bit, because if it is a '0' (indicating a positive number), then it can simply be ignored when figuring the number's magnitude. Of all possible encodings of negative numbers, two have been used most often: signed magnitude, and 2's compliment. Signed magnitude representations simply designate the MSB as the sign bit, and the remaining bits as magnitude. In an 8-bit signed-magnitude system, '16' would be represented as '00010000', and '-16' as '10010000'. This system is easy for humans to interpret, but it has a major disadvantage for digital circuits: if the 0 to 2^N count range is traversed from smallest to largest, then the largest positive number appears halfway through the range, followed immediately by the smallest negative number. Further, the largest negative number appears at the end of the range (at binary number 2^N), and counting once more results in “rollover”, since the number 2^N+1 cannot be represented. Thus, 0 follows 2^N in the count range, so the largest negative number is immediately adjacent to the smallest positive number. Because of this, a simple operation like '2–3', which requires counting backwards from two three times, will not yield the expected result of '-1', but rather the largest negative number in the system. A better system would place the smallest positive and negative numbers immediately adjacent to one another in the count range, and this is precisely what the 2's compliment representation does. The number wheels below illustrate signed-magnitude and 2's compliment encodings for 8-bit numbers.

Largest Negative Number 11111111 11111110 11111110

Smallest Postive Number (zero)

00000000

00000001 00000010 00000011

Count value "rolls over" from all 1's to all 0's

Smallest Negative Number 11111111 11111110 11111110

Smallest Postive Number (zero)

00000000

00000001 00000010 00000011

Count value "rolls over" from all 1's to all 0's

Numbers get larger in a clockwise direction

Numbers get larger in a clockwise direction

SIGNED MAGNITUDE

2's COMPLIMENT

10000011 10000010 10000001

10000000

Smallest Negative Number

01111101 01111110 01111111

Largest Postive Number

10000011 10000010 10000001

10000000

Largest Negative Number

01111101 01111110 01111111

Largest Postive Number

Figure 1. Number wheels illustrating signed magnitude and 2's complement encoding of signed numbers.

In 2's compliment encoding, the MSB still functions as a sign bit—it is always '1' for a negative number, and '0' for a positive number. The 2's compliment code has a single '0' value, defined by a bit pattern containing all 0's (including the leading '0'). This leaves 2^N - 1 codes to represent all non-zero numbers, both positive and negative. Since 2^N-1 is an odd number, we end up with 2^N/2 negative numbers, and 2^N/2 -1 positive numbers (since '0' uses one of the available codes for a positive number). In other words, we can represent one more non-zero negative number than positive, and the magnitude of the largest negative number is one greater than the magnitude of the largest positive number. The disadvantage to 2's compliment encoding is that negative numbers are not easily interpreted by humans (e.g., is it clear that '11110100' represents a -12?). A simple algorithm exists for converting a positive number to a 2's compliment-encoded negative number of the same magnitude, and for converting a 2's compliment- encoded negative number to a positive number of the same magnitude. The algorithm, illustrated in Fig. 2 below, requires inverting all bits of the number to be converted, and then adding '1' to the resulting bit pattern. The algorithm can be visualized in the 2's compliment number wheel above by noting that “inverting all bits” reflects a number around an axis drawn through '0' and the largest negative number, and “adding one” compensates for the 2's compliment code containing one more negative code than positive code.

Figure 2. Examples for converting a positive number to 2's compliment negative number.

Digital circuits that perform arithmetic functions often must deal with negative numbers, so a method of representing negative numbers must be defined. An N-bit system can represent 2N total numbers, so a useful encoding would use half the available codes (i.e., 2^N/2) to represent positive numbers, and half negative numbers. Signed magnitude representations simply designate the MSB as the sign bit, and the remaining bits as magnitude. In an 8-bit signedmagnitude system, '16' would be represented as '00010000', and '-16' as '10010000'. In 2's compliment encoding, the MSB still functions as a sign bit—it is always '1' for a negative number, and '0' for a positive number. The 2's compliment code has a single '0' value, defined by a bit pattern containing all 0's (including the leading '0'). This leaves 2^N - 1 codes to represent all non-zero numbers, both positive and negative. A simple algorithm exists for converting a positive number to a 2's compliment-encoded negative number of the same magnitude, and for converting a 2's compliment-encoded negative number to a positive number of the same magnitude.

## Learn.Digilentinc | Negative Binary Numbers

Negative Binary Numbers Signed Magnitude and 2's Compliment Digital systems have a fixed number of signals that can be used to represent binary numbe...

#### Recommend Documents

Negative Binary Numbers | Binary Arithmetic | Electronics Textbook
Only by first establishing these limits can I avoid confusion of a negative number with a larger, positive number. Repre

How Computers Represent Negative Binary Numbers? | Programming
Dec 1, 2011 - Once you learn how number systems work it's pretty easy to go from decimal to binary, back, to add binary

Negative Numbers and Binary Subtraction - Play-Hookey!
Because positive numbers are the same in both sequences, they can be used together without difficulty. We only need to k

Binary Numbers
Binary numbers. A rudimentary knowledge of how binary numbers work is required in order to understand the mechanism of d

Binary Numbers
Binary Numbers. â¢ COUNTING SYSTEMS UNLIMITED . . . Since you have been using the. 10 different digits 0, 1, 2, 3, 4, 5

Symbols : Cool Ece Digital System Design Negative Binary Numbers
Symbols : Cool Ece Digital System Design Negative Binary Numbers Converter Signedbinarynumbersforann Number 2s Complemen

Binary Numbers - RISC-Linz
Binary Numbers. Digital Computers. Todays computers are digital. â¢ Digital: data are represented by discrete pieces. â

Binary numbers - Lynda.com
Jul 14, 2016 - The binary number system uses two symbols to represent values. Using this base-2 number system, other val

What Are Binary Numbers
These zero- and one-states are the fundamentals upon which all digital logic is based. Exponentation. In order to unders

Binary Numbers | MathCaptain.com
The study of binary number system is very much important from the viewpoint of understanding how data are represented be