Professional Documents
Culture Documents
Decimal 0 ~9
Binary 0 ~1
Octal 0 ~7
Hexadecimal 0 ~F
Decimal Number
4
Decimal Number
• In decimal number system each of the ten
digits, 0 through 9
Example:
Express the decimal
number 2745.214 as a
sum of the values of
each digit
Note:
MSB = Most Significant Bit
LSB = Least Significant Bit
Decimal Number
Solution:
weights 103 102 101 100 10-110-210-3
2 7 4 5 . 2 1 4
6
Decimal Number
Questions:
a) 57
b) 387.31
c) 13.542
7
Binary Number
• The binary number system is another way to
represent quantities. There are 1 (HIGH) and 0
(LOW)
• The binary numbering system has base 2 with
each position weighted by a factor of 2:
Binary Number
• The position of each digit (bit) in a binary
number can be assigned a weight.
• For example: 1011.101
– 1011.101 is a binary number
– 1 is a digit, 0 is a digit, 1 is a digit…
1 0 1 1 . 1 0 1
9
Example
Convert the binary whole number 1101101 to
decimal:
Weight: 26 25 24 23 22 21 20
Binary Number : 1 1 0 1 1 0 1
1101101 = 26 + 25 + 2 3 + 22 + 20
= 64 + 32 + 8 + 4 + 1
= 109
Example:
binary to decimal number
weights 23 22 21 20 2-1 2-2 2-3
1 0 1 1 . 1 0 1
11
Example:
binary to decimal number
Questions:
a) 0.1101
b) 1010111
c) 101011.011
12
Binary Weight
28 27 26 25 24 23 22 21 20 . 2-1 2-2
256 128 64 32 16 8 4 2 1 Decimal 0.5 0.25
point
The left most bit is the MSB and the right most bit is LSB.
Sum-of-Weights Method
To get the binary number for a given decimal, find the binary
weights that add up to the decimal number.
Example 1:
The decimal number is 11. So you can expressed as the sum
of binary weight as follows:
11 = 8 + 2 + 1 or 11 = 23 + 21 + 20
Placing 1s in appropriate weight:
23 22 21 20
8 4 2 1
1 0 1 1
Sum-of-Weights Method
Example 2:
Given 5710
26 25 24 23 22 21 20
64 32 16 8 4 2 1
0 1 1 1 0 0 1
17
Decimal Number Binary Number
Example:
The decimal number is 0.625. So you can expressed as the sum of binary
weight as follows:
0.625 x 2 = 1.25 1
0.25 x 2 = 0.50 0
0.5 x 2 = 1.00 1
Binary Arithmetic
Example:
Binary Addition
The four basic rules for adding binary digits:
Questions:
Add the following binary numbers:
a)11 + 11
b)100 + 10
c) 111 + 11
d)110 + 100
Binary Subtraction
The four basic rules for subtracting binary digits:
Example:
Binary Subtraction
The four basic rules for subtracting binary digits:
Questions:
Subtract the following binary numbers:
a) 11-01
b) 1001-0111
c) 10101-00111
Binary Multiplication
The four basic rules for multiplication in binary digits:
Binary Division
Division in binary follows the same procedure as division in
decimal.
Example:
1 1 0 ÷ 11 = ??
Exercise
Questions:
a) 1101 x 11
b) 101 x 101
c) 1110 ÷ 10
d) 10010 ÷ 110
1’s and 2’s Complements of
Binary Numbers
• The 1’s and 2’s Complements of Binary
Numbers are very important because they
permit the representation of negative
numbers.
• The method of 2’s complement arithmetic
is commonly used in computers to handle
negative numbers
Finding the 1’s Complement
The 1’s complement of a binary number is found by
changing all 1s to 0s and all 0s to 1s.
Example:
1 0 1 1 0 0 1 0 (Binary Number)
0 1 0 0 1 1 0 1 (1’s Complement)
NOT Gate
Sign-Magnitude Form
When a signed binary number is represented in sign-magnitude, the left-
most bit is the sign bit and the remaining bits are the magnitude bits. The
magnitude bits are in true (uncomplemented) binary for both positive and
negative numbers.
Example: Decimal number, +25 is expressed as an 8-bit
signed binary number using sign-magnitude form
as:
Magnitude Bit
Sign Bit 00011001
The Sign Bit
Example
Example
Using 8-bits, decimal number for -25 is expressed as 1’s complement of +25
+25 = 00011001
= 11100110
The Sign Bit
2’s Complement Form
In the 2’s complement form, negative number is the 2’s complement of
corresponding positive number.
Example
+25 = 00011001
= 11100111
Exercise:
26 25 24 23 22 21 20
0 0 1 0 1 0 1 >> 16 + 4 + 1 = 21
The sign bit is 1: Therefore, the decimal number is -21
1’s Compliment: •Decimal Value of positive numbers in the sign-magnitude
form are determined by summing the weights in all the
magnitude bit positions where there are 1s and ignoring
those positions where there are zeros.
•Decimal values of negative numbers are determined by
assigning a negative value to the weight of the sign
bit,summing all the weights where there are 1s,and adding
1 to the result.
Determine the decimal value of this signed binary
number expressed in 1’s compliment:
a) 00010111
-27 26 25 24 23 22 21 20
0 0 0 1 0 1 1 1 >> 16 + 4 + 2 + 1 = +23
b) 11101000
-27 26 25 24 23 22 21 20
• 1 1 1 0 1 0 0 0 >> -128 + 64 + 32 + 8 = -24
•Adding 1 to the result; -24 + 1 = -23
2’s Compliment: •Decimal Value of positive and negative numbers in
the 2’s compliment form are determined by
summing the weights in all the bit positions where
there are 1s and ignoring those positions where
there are zeros. The weight of the sign bit in a
negative number is given in a negative value.
45
Binary to HEX Conversion
1. Group the binary number into group of 4-bits
2. Each group is converted to its equivalent HEX digit.
3. Zero are added as needed to complete a 4-bits group
Example
Example
1 0 A 4
0001 0000 1010 0100
HEX to Decimal Conversion
Example
161 160
Convert 1C16 to decimal 1 C
1C16 = (1 x 16) + (C x 1)
= (1 x 16) + (12 x 1)
= 2810
C16 = 1210
Decimal to HEX Conversion
Example:
• Convert 65010 to HEX
HEX Reminder
• Base-8 system
• 8 digits: 0,1,2,3,4,5,6,7
• Convenient way to express binary
numbers and codes
52
BCD
8 7 4
1000 0111 0100 = 100001110100BCD
Decimal 0 1 2 3 4 5 6 7 8 9
Digit
BCD 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Invalid Code:
The six code combination are not in used
1010, 1011, 1100, 1101, 1110, 1111
EXERCISE
1.Add the two BCD numbers, using the rules for binary addition
Add 6(0110) to the for bit sum in order to skip the six invalid
states and return the code to 8421. If a carry results when 6
is added, simply add the carry to the next 4 bit group.
EXAMPLE
0011 1001
+ 0100 + 0100
0111 1101 Invalid BCD number (>9)
+ 0110 Add 6(0110)
0001 0011 Valid BCD number
1 3
EXERCISE
Add the following BCD numbers
a) 0011 + 0100
b) 1001 + 0100
c) 10000110 + 00010011
d) 01100111 + 01010011
e) 00010110 + 00010101
Alphanumeric codes
1011001
processor
Thank You