Chapter1 Log New 25
Chapter1 Log New 25
• Course Description
This course focuses on the fundamental constructs and concepts underlying
computer hardware and software which includes: number systems, binary
arithmetic, codes, Boolean algebra, gates, Boolean expressions
1. Digital Systems
2. Binary Numbers
3. Number‐Base Conversions
4. Octal and Hexadecimal Numbers
5. Arithmetic Operations
6. Complements of Numbers
7. Signed Binary Numbers
8. Binary Codes
9. Binary Storage and Registers
10. Binary Logic
Analog and Digital Signal
Analog systemاالشاره التناضريه
The physical quantities or signals may vary continuously over a specified range.
1. Digital Computers
2. Telephone switching exchanges
3. Digital camera
4. Electronic calculators, PDA's Digital TV
Digital Systems
Coefficient Position
◆ Integer & fraction
Coefficient Weight
◆ Weight = (Base) Position
In general Magnitude:
◆ Sum of “Coefficient x Weight”
Binary Numbers
Base = 2
◆ 2 digits { 0, 1 }, called binary digits or “bits”
Weights
◆ Weight = (Base) Position
Magnitude
◆ Sum of “Bit x Weight”
Formal Notation
Groups of bits
The Power of 2
Octal Number System
Base = 8
◆ 8 digits { 0, 1, 2, 3, 4, 5, 6, 7 }
Weights
◆ Weight = (Base) Position
Magnitude
◆ Sum of “Digit x Weight”
Formal Notation
Hexadecimal Number System
Base = 16
◆ 16 digits { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F }
Weights
◆ Weight = (Base) Position
Magnitude
◆ Sum of “Digit x Weight”
Formal Notation
Number Base Conversions
1. To convert a decimal integer into any base, keep dividing by r until the quotient is 0.
Collect the remainders in reverse order.
2. To convert a fraction, keep multiplying the fractional part by r until it becomes 0 or
until we reach the required accuracy. Collect the integer parts in forward order.
Decimal (Integer) to Binary Conversion
ANSWER 100
Decimal to Hexadecimal Conversion
ANSWER 399
Decimal to Hexadecimal Conversion
ANSWER BC
Conversion form any base to Decimal (Evaluate magnitude)
Conversion form binary to Decimal (Evaluate magnitude)
To convert a binary number to a decimal number, you can follow these steps:
1.Start with the rightmost digit of the binary number.
2.Multiply this digit by the corresponding power of 2.
3.Repeat steps 1 and 2 for each digit in the binary number.
4.Add the results of all the multiplications to get the decimal number.
For example, to convert the binary number 1101 to decimal, we would follow these
steps: 1.Write the binary number down: 1101
2.Starting from the rightmost digit, multiply each digit by the corresponding
power of 2:
1. 1×20=1
2. 0×21=0
3. 1×22=4
4. 1×23=8
3.Add the results together: 1 + 0 + 4 + 8 = 13
4.The final result is the decimal equivalent of the binary number: 13
Conversion form binary to Decimal (Evaluate magnitude)
= (1 2 7 4) 5 101
6 110
= (1274)
Conversion form binary to Octal
table. 1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
Conversion form binary to Hexadecimal
1. Convert the octal number into binary and then convert the binary into hexadecimal.
2. Convert the octal number into decimal and then convert the decimal into hexadecimal.
Conversion form binary to Hexadecimal
Example :Convert (56)8 into hexadecimal
Step 1 : Convert (56)8 into Binary
In order to convert the octal number into binary, we need to express every octal value
using 3 binary bits.
Binary equivalent of 5 is (101)2.
Binary equivalent of 6 is (110)2.
= (56)8
= (101)(110)
= (101110)2
Step 2 : Convert (101110)2 into Hexadecimal
In order to convert the binary number into hexadecimal, we need to group every 4 binary bits and calculate
the value[From left to right].
(101110)2 in hexadecimal
= (101110)2
= (10)(1110)
= (2)(14)
= (2E)16
Conversion form Octal to Hexadecimal
In general, the result of adding two digits each of weight w is two digits. One is the “Sum”
digit and the other is the “Carry” digit.
In binary system, if the weight of the sum bit is 2i, then the weight of
the carry bit is 2i+1. Thus, adding 1 + 1 in the binary system results in
a Sum bit of 0 and a carry bit of
Single Bit Binary Addition
Q. What is 1 + 1 + 1 = ?
A. The answer is 1 carry 1.
Another Example:
Q. What is1–1–1=?
A. The answer is 1 borrow 1.
Explanation: We perform the operation in 2 steps: 1 – 1 = 0
We then subtract 1 from the above result, i.e. 0 – 1 which is
1 borrow 1.
Q. What is 0 – 1 – 1 = ?
A. The answer is 0 borrow 1. Explanation: We perform the
operation 0 - 1= 1 borrow 1
We then subtract 1 from the above result, which yields 0
borrow 1.
Example :
Complements
11111111
Complements
2’s Complement (Radix Complement)
Take 1’s complement then add 1
OR Toggle all bits to the left of the first ‘1’ from the right( least significant 1)
Binary Subtraction Using 1’s Complements
The subtraction of two n bit unsigned binary numbers X –Y using the 1’s complement can
be done as follows:
• Take the 1’s complement of the subtrahend Y and add it to the minuend X.
If X >= Y, the sum will produce and end carry at position 2n, which is added to LSB of
the sum. This operation is called end a round carry.
If X < Y, the sum does not produce an end carry. To obtain the answer in a familiar
form, take the 1’s complement of the sum and place a negative sign in front.
Binary Subtraction Using 1’s Complement
Example:
Binary Subtraction Using 1’s Complement
Example :
Given the two binary numbers X = 1101 and Y = 10, perform the subtraction X – Y by
using 1's complement.
1101 – 10 = 1011
Binary Subtraction Using 1’s Complement
perform the subtraction by using 1’s complements
• Take the 2’s complement of the subtrahend Y and add it to the minuend X.
• If X >= Y, the sum will produce and end carry at position 2n, which can be
discarded; what is left is the result X – Y.
• If X < Y, the sum does not produce an end carry. To obtain the answer in a familiar
form, take the 2’s complement of the sum and place a negative sign in front.
Binary Subtraction Using 2’s Complement
Example
Given the two binary numbers X = 1010100 and Y = 1000011, perform the
subtraction (a) X – Y ; and (b) Y X, by using 2's complement.
Examples :
Q 1. Given the two binary numbers X = 1001 and Y = 0101, perform the
Q 2. Given the two binary numbers X = 1010010 and Y = 11100100, perform the
(a) X – Y
Registers are fast storage devices used inside processors Used to store computation
results of a running program
A Register consists of a fixed number of storage bits
Signed-2’s Complement representation: 11110111 All three use the left most bit to represent the sign:
» ‘0’ positive
» ‘1’ negative
• How to represent characters, colors, etc? Define the set of all represented
elements.
• Assign a unique binary code to each element of the set. Given n bits, a binary code is a
As a minimum, we need 3 bits to define 7 unique values. 3 bits define 8 possible combinations.
Orange 001
Yellow 010
Green 011
Blue 100
Indigo 101
Violet 110
Decimal Codes
• Binary number system is most natural for computers. But people are used to the
decimal system.
• Must convert decimal numbers to binary, do arithmetic on binary numbers, then
convert back to decimal.
• To simplify conversions, decimal codes can be used. Define a binary code for each
decimal digit.
• Since 10 decimal digits exit, a 4-bit code is used. But a 4-bit code gives 16
unique combinations. 10 combinations are used and 6 will be unused.
Binary Coded Decimal
• A decimal number in BCD is the same as its equivalent binary number only when the
number is between 0 and 9.
• The binary combinations 1010 through 1111 (10 – 15) are not used and have no meaning
in BCD (i.e. invalid combinations)
Warning: Conversion or Coding?
Do NOT mix up conversion of a decimal number to a binary number with coding a decimal
number with a binary code
Single Digit BCD Addition
Example :
Convert the decimal digit 5 from:
•BCD (8421)
BCD (8421) for 5 = 0101
•Excess-3
Excess-3 = BCD + 3 = 0101 + 0011 = 1000
•2421
2421 for 5 = 1011
• 8,4,-2,-1
8,4,-2,-1 for 5=1011
Other Decimal Codes
Excess-3 , 2421 and 8,4,-2,-1 are self-complementing codes
(i.e. the 9’s complement of the decimal number is obtained by changing 1’s
to 0’s and 0’s to 1’s.)
Note that the codes for 0 and 9, 1 and 8, etc. can be obtained from each other
by replacing the 0’s with the 1’s and vice-versa in the code words.
Binary : 10111
Binary : 110111
ASCII Character Code
Registers:
◆A binary cell is a device that possesses two stable states and is capable of storing
one of the two states(i.e. Each cell stores one bit of information. Examples: flip-
flop, capacitor.
◆A register is a group of binary cells. Example: AX in x86 CPU.
A register with n cells can store any discrete quantity of information that contains
n bits.
Binary Logic
Definitions of logical operations may be listed in a compact form called truth tables. A truth
table is a table of all possible combinations of the variables, showing the relation between
the values that the variables may take and the result of the operation
Logic gates
Logic gates are electronic circuits that operate on one or more input signals to produce
an output signal.
Logic gates