Swidlec Lecture 01
Swidlec Lecture 01
The foundation of digital computer was laid upon the invention of some computing
machines by an eccentric British mathematician Charles Babbage (1791-1871).
The first functional digital computer was invented at Harvard University in 1944.
However, it was not an electronic computer, but an electromechanical computer.
The ENIAC machine occupied a room thirty by fifty feet. The controls
are at the left, and a small part of the output device is seen at the right. The two
men in uniform were being trained to maintain the machine after it was turned
over to the Ordnance Department (which sponsored the development of the
ENIAC). The two women were assistants on the staff of the Moore School who
helped program the ENIAC.
CONTROL
UNIT
PROCESSOR
or
ARITHMETIC
UNIT
STORAGE
or
MEMORY UNIT
INPUT
DEVICE
OUTPUT
DEVICE
Digital Quantity
Analog Signal
SWITCHING THEORY
DIGITAL SYSTEM
Receives,
stores,
manipulates
and
communicates information in discrete form.
Is any system intended for the transmission or
processing of information in which information is represented by physical
quantities (signals) that are so constrained as to take on only discrete values.
BINARY SYSTEM
Is the number system with only two distinct discrete values, 0 and 1 called bits. The
term bits is a contraction of the words binary digit.
In digital circuits, two different voltage levels are used to represent the two bits.
HIGH = 1
LOW = 0
HIGH = 0
LOW = 1
BINARY CODES
000101011101010101010000011110101010111100001010101000001110101001010101101
LOGIC LEVELS
VH(max)
HIGH
(binary 1)
VH(min)
Unacceptable
VL(max)
LOW
(binary 0)
VL(min)
NUMBER SYSTEMS
Base/Radix
Number System
2
3
4
5
6
7
8
9
10
11
12
16
20
60
Binary or Dyadic
Ternary
Quaternary
Quintary
Senary
Septenary
Octal or Octenary
Nonary
Decimal or Decadic or Denary
Undenary
Duodecimal or Duodenary
Hexadecimal or Hexadecadic
Vigesimal or Vicenary
Sexagesimal
Generalizations:
The number of symbols is equivalent to the decimal value of the radix.
The last symbol is always equivalent to the decimal value of the radix minus 1.
In counting, the count after the last digit is always 10. The weight of 10 is equivalent
to the decimal value of the radix.
NUMBER REPRESENTATIONS
Given a number, (N.F) r, this can be represented in two forms.
N whole part/integer part
F fractional part
. radix point
r radix
A. POLYNOMIAL REPRESENTATION
2. Base 10 to Base r
START
START
Divide by r
Multiply by r
Q=0
F=0
END
END
(1011 . 01)2
(0110 .10 )2
(1011 .11)2
( 101 .11)2
(127 .2 )8
(110 .5 )8
(127 .2 )8
(767 .7 )8
(AB.C)H
( 11 .2 )H
(AB.C)H
(FE.D)H
(78. 2)8
(12 .3)8
(1011 .11)2
(1010 .10 )2
(1000 . 01)2
( 111 .11)2
(72.1)8
(51.1)8
(125. 3)8
( 77.4 )8
(AB.C)H
( 19 .8)H
(F 9.8 )H
(AB.C)H
(101 .1)2
(11)2
(77. 1)8
(12 )8
(11)2 (10101)2
COMPLEMENTS OF NUMBERS
The 1s complement and the 2s complement of a binary number are important
because they permit the representation of negative numbers. The method of 2s complement
arithmetic is commonly used in computers to handle negative numbers.
A. Diminished Radix Complement [(r-1)s complement]
(N )r 1,c = r n r m N
(147)9,c =
(0.53)9,c =
(147.53)9,c =
(1010) 1,c =
(N )r , c
= rn N
[N 0]
(147)10,c =
(0.53)10,c =
(147.53)10,c =
(453)8,c =
(1010) 2,c =
Alternative Solution: for binary numbers: start at the right with the LSB,
write the bits as they are up to and including the
first 1 and then, invert the remaining bits;
for all systems: subtract the LSB from r and subtract
all other digits from (r-1)1
Still another solution: for all systems: take the rs complement and add 1.
M
M
-- S
S
D
D
EXERCISES:
Solve using rs complement:
47 10
34 10
1310
47 10
34 10
47 10
1310
30 8
30
+ 8
118
17 8
34 10
118
11
+ 8
30 8
17 8
4710
47
+ 10
3410
1310
30 8
118
17 8
30 8
3410
34
+ 10
4710
1310
118
30 8
17 8
118
There are three ways in which signed integer (whole) numbers can be represented in
binary form:
1.) Sign-Magnitude
2.) 1s complement
3.) 2s complement
For non-integer and very large or small numbers, they can be represented/expressed in
floating-point format.
00011001
Sign Bit
Magnitude bits
10011001
Sign Bit
Magnitude bits
11100110
In the 1s complement system, a negative number is the 1s
complement of the corresponding positive number.
11100111
In the 2s complement system, a negative number is the 2s
complement of the corresponding positive number.
Exercises:
Express the decimal number 39 as an 8-bit number in signmagnitude, 1s complement, and 2s complement systems.
COMPUTER NOTE:
Computers use the 2s complement for negative integer numbers
in all arithmetic operations. The reason is that subtraction of a number is
the same as adding the 2s complement of the number. Computers form the
2s complement by inverting the bits and adding 1 using special instructions.
Decimal values of positive and negative numbers in the sign-magnitude system are
determined by summing the weights in all the magnitude bit positions where there are
1s and ignoring those positions where there are zeros.
The sign is determined by examination of the sign bit.
Example:
Determine the decimal value of this signed binary number expressed in sign-magnitude:
10010101.
1S COMPLEMENT
Example:
Determine the decimal values of the signed binary numbers expressed in 1s complement:
(a) 00010111
(b) 11101000
2S COMPLEMENT
Decimal values of positive and negative numbers in the 2s complement systems are
determined by summing the weights in all bit positions where there are 1s (including
the sign bit) and ignoring those positions where there are zeros.
The weight of the sign bit in a negative number is given a negative value.
Example:
Determine the decimal values of the signed binary numbers expressed in 2s complement:
(a) 01010110
(b) 10101010
Total Combinations = 2
For 2s complement signed numbers, the range of values for n-bit numbers is
n-1
-(2 ) to +(2
n-1
-1)
where in each case there is one sign bit and n-1 magnitude bits.
FLOATING-POINT NUMBERS
This type of representation is based on scientific
notation. It is capable of representing very large and
very small numbers without an increase in the number
of bits. Floating point numbers are used to represent
very large integer (whole) numbers and numbers with
both integer and fractional parts.
A floating point number (also known as a real number) consists of two parts plus a
sign: MANTISSA - part of a floating-point number that represents the magnitude of the
number; EXPONENT - part of a floating-point number that represents the number of
places that the decimal point (or binary point) is to be moved.
To illustrate, consider the decimal integer number: 241,506,800.
The mantissa is:
The exponent is:
.2415068
9
0.2415068 x 10
Binary Floating-Point Numbers
ADDITION
Conditions when adding two numbers:
Case I: Both numbers positive.
Case II: Positive number with magnitude larger than negative number.
Case III: Negative number with magnitude larger than positive number.
Case IV: Both numbers negative.
00000111
00000100
00001011
4
11
00001111
11111010
1 00001001
15
6
9
The final carry bit is discarded. The sum is positive and therefore in true
(uncomplemented) binary.
Case III: Negative number with magnitude larger than positive number.
+
00010000
11101000
11111000
16
24
8
11111011
11110111
11110010
9
14
The final carry bit is discarded. The sum is negative and therefore in 2s
complement form.
ADD THE TWO NUMBERS AND DISCARD ANY FINAL CARRY BIT.
OVERFLOW CONDITION
When two numbers are added and the number of bits required to
represent the sum exceeds the number of bits in the two numbers, an
OVERFLOW results as indicated by an incorrect sign bit. An overflow
can occur only when both numbers are positive or both numbers are
negative.
Example : Perform (+125) + (+58) in binary.
SUBTRACTION
Subtraction is a special case of addition. Basically, the subtraction operation changes
the sign of the subtrahend and adds it to the minuend. The result is called the difference.
Perform the following subtractions of the signed numbers:
(a)
(b)
(c)
(d)
00001000
00001100
11100111
10001000
00000011
11110111
00010011
11100010
BINARY CODES
Recall:
binary
conversion
binary
coding
...010100101010101
111001110001010...
binary number
binary code
Binary Conversion:
The bits obtained are binary digits and they form a binary number.
Binary Coding
Bits obtained are arranged according to the rules of the code used. The output is a
binary code.
2 N
B
log 10 N
= log 2 N
log 10 2
Example:
There are eight different colors, represent each color with a unique binary code.
There are 5 different signs, represent each sign with a unique binary code.
2. BINARY CODED DECIMAL or BCD
It is a binary code for decimal digits. It means that each decimal digit, 0 through 9, is
represented by a binary code of four bits and at least 6 unassigned code words.
DECIMAL
DIGIT
4
0
0
0
0
1
1
1
2
0
0
1
1
0
0
1
84-2-1
0
1
2
3
4
5
6
8
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
7
8
9
0 1 1 1
1 0 0 0
1 0 0 1
8
0
0
0
0
0
1
1
4
0
1
1
1
1
0
0
7421
4
0
0
0
0
1
1
1
2
0
0
1
1
0
0
1
5421
-2
0
1
1
0
0
1
1
-1
0
1
0
1
0
1
0
7
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1 0 0
1 0 0
1 1 1
1
0
1
1 0 0 0
1 0 0 1
1 0 1 0
5
0
0
0
0
0
0
0
4
0
0
0
0
1
1
1
2
0
0
1
1
0
0
1
2421
1
0
1
0
1
0
1
0
0 1 1 1
1 0 1 1
1 1 0 0
2
0
0
0
0
0
1
1
4
0
0
0
0
1
0
1
2
0
0
1
1
0
1
0
BIQUINARY
1
0
1
0
1
0
1
0
1 1 0 1
1 1 1 0
1 1 1 1
5
0
0
0
0
0
1
1
0
1
1
1
1
1
0
0
4
0
0
0
0
1
0
0
3
0
0
0
1
0
0
0
2
0
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1 0 0 0 1 0 0
1 0 0 1 0 0 0
1 0 1 0 0 0 0
EXCESS 3 (XS3)
XS3
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
a) Gray Code
GRAY
CODE
000
001
011
010
110
111
101
100
EVEN PARITY
P
0
1
1
0
1
0
0
1
1
0
BCD
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
ODD PARITY
P
1
0
0
1
0
1
1
0
0
1
BCD
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
c) Alphanumeric Codes
In the strictest sense, alphanumeric codes are codes that represent numbers and
alphabetic characters (letters). Most such codes, however, also represent other
characters such as symbols and various instruction necessary for conveying
information.
c.1) ASCII American Standard Code for Information Interchange
It is a universally accepted alphanumeric code used in most computers and
other electronic equipment.
ASCII has 128 characters and symbols represented by a 7-bit binary code.
Actually, ASCII can be considered an 8-bit code with the MSB always zero.
The first thirty-two are nongraphic commands that are never printed or
displayed and used only for control purposes.
c.2) EBCDIC Extended Binary Coded Decimal Interchange Code
Proposed by IBM
Composed of 8 bits but only half of the 256 combinations are actually used.
SWIDLEC Lecture Notes
Edzel R. Lapira
[email protected]