REPRESENTATION OF INTEGERS IN THE COMPUTER SYSTEM
In mathematics, positive numbers (including zero) are represented as unsigned
numbers. That is we do not put the +ve sign in front of them to show that they are
positive numbers. But when dealing with negative numbers we do use a -ve sign in front
of the number to show that the number is negative in value and different from a positive
unsigned value, and the same is true with signed binary numbers. However, in digital
circuits there is no provision made to put a plus or even a minus sign to a number, since
digital systems operate with binary numbers that are represented in terms of “0’s” and
“1’s”.
Unsigned numbers represent only positive values while signed numbers handle both
positive and negative values using methods like two’s complement. For signed binary
numbers the most significant bit (MSB) is used as the sign bit. If the sign bit is “0”, this
means the number is positive in value. If the sign bit is “1”, then the number is negative
in value. The remaining bits in the number are used to represent the magnitude of the
binary number in the usual unsigned binary number format way.
Positive Signed Binary Numbers
Negative Signed Binary Numbers
A signed integer is an integer with a positive '+' or negative sign '-' associated with it.
Since the computer only understands binary, it is necessary to represent these signed
integers in binary form.
Range of Sign-Magnitude Representation
-2n-1 - 1 to + 2n-1 – 1 where n is the number of bits
In binary, signed Integer can be represented in three ways:
1. Signed bit.
2. 1’s Complement.
3. 2’s Complement.
Sign-Magnitude Representation
Example (4-bit):
Decimal Binary
+3 0011
-3 1011
In 8-bit system
Decimal number +25 is represented as 00011001 (Sign bit 0, magnitude 25)
Decimal number -25 is represented as 10011001 (Sign bit 1, magnitude 25)
-12710 as a 8-bit number is 111111112
-1510 as a 6-bit number is 1011112
ONE’S COMPLEMENT OF A SIGNED BINARY NUMBER
One’s Complement or 1’s Complement as it is also termed, is another method which we
can use to represent negative binary numbers in a signed binary number system. In
one’s complement, positive numbers (also known as non-complements) remain
unchanged as before with the sign-magnitude numbers.
Negative numbers however, are represented by taking the one’s complement (inversion,
negation) 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
counterpart, so to take the one’s complement of a binary number, all we need to do is
change each bit in turn. Thus the one’s complement of “1” is “0” and vice versa, then the
one’s complement of 100101002 is simply 011010112 as all the 1’s are changed to 0’s
and the 0’s to 1’s.
Decimal number +18 is represented as 00010010
Decimal number -18 is represented as 11101101 (All bits flipped)
-4 is represented as 1011 in a 4-bit system
-7 is represented as 1000 in a 4-bit system
Subtraction using One’s Complement
Perform this arithmetic operation using 1’s complement
A. 11002 – 01012
B. 115 – 27
Soln
A. (– 01012) is converted to = 10102
1100
+ 1010
Calculation:
𝟏 0110
Add the end around carry of 1 to the answer to get actual result
0110
+ 1
0111
B. 115 – 27
Convert both to their respective binary representation.
11510 in binary is: 011100112
2710 in binary is: 000110112
27 is a negative number, since we are using 1’s complement, we will change all the 1’s
to 0’s and 0’s to 1’s. Resulting value 00011011 = 11100100.
01110011
+ 11100100
Calculation:
𝟏 01010111
The 8-bit result from above is: 01010111 (the overflow “1” cancels out) and to convert it
to the real 1’s complement answer, we now have to add the carry “1” to the one’s
complement result.
01010111
+ 1
01011000
NB: If there is no carry of 1 the result remains unchanged and is only inverted to
1’s complement to check for correct decimal value
Eg. 01012 - 11002
Negative 1100 inverted to 0011
0101
+ 0011
= 1000 is the result. To find its decimal value:
(𝑐𝑎𝑟𝑟𝑦=0) 1000
Invert it: 1000 → 0111
So magnitude = 7 Result = −7
2's COMPLEMENT REPRESENTATION
2's complement forms negative numbers by inverting all bits of the positive value
and adding 1. Decimal number -20 is represented as 11101100 (Invert bits:
11101011, then add 1).
Example
1. Convert the binary number 10110101 into its 2’s complement form.
Invert 10110101 to 1’s complement = 01001010
Add 1 to 01001010 to get the two’s complement = 01001011
2. -5 + 3 using two’s complement assume 4-bit representation
3 in binary = 0011
5 in binary = 0101
The number 5 is negative, hence by using 2’s complement convert to 1’s
complement then add 1 to it.
1’s complement of -5 = 1010
2’s complement of -5 =1010 + 1 = 1011
Calculation of -5+3 = 1011 + 0011
1011
+ 0011
1110
Carry is 0 indicating negative, now convert 1110 to 1’s complement = 0001, then add 1,
0001 +1 = 0010(represents 2, hence 1110(-2) is its two’s complement which is the
answer we got after the calculation)
3. Solve this (1010)2 + (1111)2 using 2’s complement method.
Signed
Signed Signed One’s
Decimal Two’s
Magnitude Complement
Complement
+7 0111 0111 0111
+6 0110 0110 0110
+5 0101 0101 0101
+4 0100 0100 0100
+3 0011 0011 0011
+2 0010 0010 0010
+1 0001 0001 0001
+0 0000 0000 0000
-0 1000 1111 –
-1 1001 1110 1111
-2 1010 1101 1110
-3 1011 1100 1101
-4 1100 1011 1100
-5 1101 1010 1011
FOR GROUP 1
COMPLEX INSTRUCTION SET COMPUTERS (CISC)
This was adapted and developed by Intel in 1978 with the advent of the 1886
processors (286, 386, 486). It was designed to process 16 bits data ware and it has no
instruction for floating points.
Characteristics
1. It uses large number of instructions
2. It uses many different addressing modes
3. It uses variable length of instructions. i.e It can be 4,8 or 16 bits making it difficult
to identify any occurring errors due to this inconsistency.
4. All instructions to these processors are first manipulated in the main memory
before onward translated to the microprocessor for final execution.
REDUCED INSTRUCTION SET COMPUTERS (RISC)
Until the mid-90’s all processors were designed using the CISC which were large set of
instructions. The RISC was introduced to counter this issue.
Characteristics
1. It required few instructions.
2. All instructions were of the same length.
3. Most instructions were executed in one machine cycle within the microprocessor
4. The control unit was hardwired. Thus, does not use an algorithm when executing
any command.
5. Used few addressing modes and the structure were the same.
6. The internal data register size s comparatively larger than CISC.
PROCESSOR SPECIFICATION
Processors are identified by two main parameters, that is the width and the speed of
the processor.
The speed is fairly simple and measured in in Hertz (Hz) which means millions of cycles
in second. The faster the speed the better the performance.
The width does not correspond to the physical size of the processor but are rather
related to the busses that comes with the processors. These buses are:
Data Input Output bus size
The internal register bus size
The memory address bus size