Professional Documents
Culture Documents
Lecture 1b - Number System - 0
Lecture 1b - Number System - 0
1
Decimal Numbers
2
Binary Numbers
Decimal Binary Number Decimal Binary Number
Number Number
0 0 0 0 0 8 1 0 0 0
1 0 0 0 1 9 1 0 0 1
2 0 0 1 0 10 1 0 1 0
3 0 0 1 1 11 1 0 1 1
4 0 1 0 0 12 1 1 0 0
5 0 1 0 1 13 1 1 0 1
6 0 1 1 0 14 1 1 1 0
7 0 1 1 1 15 1 1 1 1
3
Binary – to – Decimal Conversion
Convert the binary whole number 1101 101 to
decimal
Weight : 26 25 24 23 22 21 20
Binary number: 1 1 0 1 1 0 1
1101101 = 26+25+24+23+22+21+20
= 64+32+8+4+1
= 109
4
Decimal – to – Binary Conversion
Sum – of – Weight Method
Solution :
9 = 8 + 1 or 9 = 2 + 2
3 0 23 22 21 20
1 0 0 1
5
Decimal – to – Binary Conversion
Repeated Division – by – 2 Method
MSB – most
significant bit
LSB – least
significant bit
6
Binary Arithmetic
Binary addition
The four basic rules for adding binary digits
(bits) are as follows:
7
Binary Arithmetic
Binary addition - Example
Carry bits
8
Binary Arithmetic
Binary Subtraction
The four basic rules for subtracting bits are as
follows:
1–1 =0
1–0 =1
10 – 1 = 1 0 – 1 with a borrow of 1
9
Binary Arithmetic
Binary Multiplication
The four basic rules for multiplying bits are as
follows:
0x0=0
0x1=0
1x0=0
1x1=1
10
1’s Complement of Binary Numbers
The 1’s complements is important because it
permits the representation of negative
numbers.
The 1’s complement of a binary number is
found by changing all 1s to 0s and all 0s to 1s.
11
1’s Complement of Binary Numbers
Application example
Simplest way is to use parallel inverters.
12
2’s Complement of Binary Numbers
Is found by adding1 to the LSB of the
1’s complement.
14
Signed Numbers
Digital systems, such as the computers, must
be able to handle both positive and negative
numbers.
A signed binary numbers consist of both sign
and magnitude information.
The sign indicates whether a number is positive
or negative and the magnitude is the value of
the number.
Three forms in which integer number can be
represented in binary.
15
Signed Numbers
Sign Bit
16
Signed Numbers
Sign – Magnitude Form
The left – most bit is the sign bit and the
remaining bits are the magnitude bits.
Example : + 25 00011001
Example : - 25 10011001
Sign bit Magnitude bits
17
Signed Numbers
1’s Complement Form
18
Signed Numbers
2’s Complement Form
19
Examples
1. Add the signed numbers: 01000100,
00011011, 00001110 and 00010010
2. Perform each of the following
subtractions of the signed numbers:
a) 10001000 - 11100010
b) 00001100 - 11110111
c) 00001000 - 00000011
d) 11100111 - 00010011
20
Examples
Arithmetic Operations with Signed Numbers
Using the signed number notation with negative
numbers in 2’s complement form simplifies addition
and subtraction of signed numbers.
Rules for addition: Add the two signed numbers. Discard
any final carries. The result is in signed form.
Examples:
00011110 = +30 00001110 = +14 11111111 = 1
00001111 = +15 11101111 = 17 11111000 = 8
00101101 = +45 11111101 = 3 1 11110111 = 9
Discard carry
21
Examples
Arithmetic Operations with Signed Numbers
Rules for subtraction: 2’s complement the subtrahend and
add the numbers. Discard any final carries. The result is in
signed form.
Repeat the examples done previously, but subtract:
00011110 (+30) 00001110 (+14) 11111111 (1)
00001111 –(+15) 11101111 –(17) 11111000 –(8)
2’s complement subtrahend and add:
00011110 = +30 00001110 = +14 11111111 = 1
11110001 = 15 00010001 = +17 00001000 = 8
1 00001111 = +15 00011111 = +31 1 00000111 = +7
Discard carry Discard carry
22
Overflow
• happens when both numbers are positive
or both numbers are negative
• Example: 0111101 + 00111010 = ??
– needs 8 magnitude bits but only 7 magnitude
bits are available
– range from -128 to +127
23
Hexadecimal Numbers
Has sixteen digits and is used primarily as a
compact way of displaying or writing binary
numbers because it is very easy to convert
between binary and hexadecimal.
It is composed of sixteen digits and alphabetic
characters.
The hexadecimal number system consist of
digits 0 – 9 and letters A – F.
24
Hexadecimal Numbers
Decimal Binary Hexadecimal Decimal Binary Hexadecimal
0 0000 0 8 1000 8
1 0001 1 9 1001 9
2 0010 2 10 1010 A
3 0011 3 11 1011 B
4 0100 4 12 1100 C
5 0101 5 13 1101 D
6 0110 6 14 1110 E
7 0111 7 15 1111 F
25
Binary – to – Hexadecimal
Conversion
Simply break the binary number into 4 – bit
groups, starting the right – most bit and
replace each 4 – bit group with the equivalent
hexadecimal symbol.
Example : 1100101001010111
26
Hexadecimal – to – Binary
Conversion
Reverse the process of Binary – to –
Hexadecimal and replace each hexadecimal
symbol with appropriate four bits.
Example : 10A416
1 0 A 4
1 0000 1010 0100
27
Hexadecimal – to – decimal
Conversion (Method 1)
Convert hexadecimal number to binary number first,
then convert from binary to decimal.
Hexadecimal to binary: 1 C
0001 1100
Binary to decimal: 24 23 22 21 20
1 1 1 0 0
16+8+4=2810
28
Hexadecimal – to – decimal
Conversion (Method 1)
Another way : multiply the decimal value of each
hexadecimal digit by its weight and then take the
sum of the products.
29
Decimal – to Hexadecimal
Conversion
Repeated division of a decimal number by 16
Example : 650 decimal to hexadecimal
30
Hexadecimal Addition
Rules :
1. In any given column of an addition problem,
think of the two hexadecimal digits in term of
their decimal values. Example, 516 = 510 and
C16 = 1210
2. If the sum of these two digits is 15 10 or less,
bring down the corresponding hexadecimal
digit.
3. If the sum of these two digits is greater than
1510, bring down the amount of the sum that
exceeds 1610 and carry 1 to the next column.
31
Hexadecimal Addition
Example :
32
18B16
Hexadecimal (FF-2A= ??)
33
Examples
1. Convert B2F816 to decimal
2. 2B16 + 8416
3. 5816 + 2216
5. 8416 – 2A16
6. C316 – 0B16
34
Octal Numbers
Composed of eight digits which are
0, 1, 2, 3, 4, 5, 6, 7
35
Octal – to – Decimal Conversion
Example : 23748
Weight : 83 82 81 80
Octal number: 2 3 7 4
36
Decimal – to – Octal Conversion
37
Octal – to – Binary Conversion
Octal Digit 0 1 2 3 4 5 6 7
1 3
001 011
38
Binary – to – Octal Conversion
Reverse process of octal – to – binary
conversion.
110 101
6 5
39
Gray Code
Unweighted and is not an arithmetic code; that
is, there are no specific weights assigned to the
bit position.
Important feature : it exhibits only a single bit
change from one code word to the next
sequence.
40
Examples
1. 1258 = 10
2. 7238 = 2
3. 9810 = 8
41
Gray Code
Decimal Binary Gray code Decimal Binary Gray code
42
Binary – to – Gray Code Conversion
Rules :
The most significant bit (left – most) in the Gray code is
the same as the corresponding MSB in the binary
number.
Going from left to right, add each adjacent pair of binary
code bits to get the next Gray code bit. Discard
carries.
Example : 10110 to gray code. (11101)
43
Gray – to – Binary Conversion
Rules :
The most significant bit (left – most) in the binary code
is the same as the corresponding bit in the Gray code.
Add each binary code bit generated to the Gray code bit
in the next adjacent position. Discard carries.
Example : gray code word 11011 to binary
44
Examples
1. Convert binary number 11000110 to
Gray code
45
Decimal Binary BCD
BCD 0 0000 0000
1 0001 0001
Binary coded decimal (BCD) is a 2 0010 0010
weighted code that is commonly 3 0011 0011
used in digital systems when it is 4 0100 0100
5 0101 0101
necessary to show decimal 6 0110 0110
numbers such as in clock displays. 7 0111 0111
The table illustrates the 8 1000 1000
difference between straight binary and 9 1001 1001
BCD. BCD represents each decimal 10 1010
digit with a 4-bit code. Notice that the 11 1011
codes 1010 through 1111 are not used in 12 1100
BCD. 13 1101
14 1110
15 1111
46
Examples
Add the following BCD:
a) 0011 + 0100
b) 00100011 + 00010101
c) 1001 + 0100
47
ASCII
Abbreviation for American Standard Code for
Information Interchange.
Pronounced as ‘askee’.
Universally accepted alphanumeric code used in the
most computers and other electronic equipments.
Most computer keyboards are standardized with the
ASCII.
Example : when enter a letter, number, or control
command, corresponding ASCII code goes into
computer.
48
ASCII
Has 128 characters and symbols represented by a 7 –
bit binary code.
It can be considered an 8 – bit code with MSB always 0.
8 – bit code is 00 through 7F in hexadecimal.
The first 32 ASCII characters are nongraphic commands
that are never printed on displayed and are used only for
control purposes.
Example : null, line feed, start of text, and escape.
The other characters are graphic symbols that can be
displayed and printed and include letters, numbers, ten
decimal digits, punctuation signs, and other commonly
used symbols.
49
1. For the binary number 1000, the weight of the column
with the 1 is
a. 4
b. 6
c. 8
d. 10
50
© 2008 Pearson Education
2. The 2’s complement of 1000 is
a. 0111
b. 1000
c. 1001
d. 1010
51
© 2008 Pearson Education
3. The fractional binary number 0.11 has a decimal value
of
a. ¼
b. ½
c. ¾
d. none of the above
52
© 2008 Pearson Education
4. The hexadecimal number 2C has a decimal equivalent
value of
a. 14
b. 44
c. 64
d. none of the above
53
© 2008 Pearson Education
5. The number 1010 in BCD is
a. equal to decimal eight
b. equal to decimal ten
c. equal to decimal twelve
d. invalid
54
© 2008 Pearson Education
6. An example of an unweighted code is
a. binary
b. decimal
c. BCD
d. Gray code
55
© 2008 Pearson Education
7. An example of an alphanumeric code is
a. hexadecimal
b. ASCII
c. BCD
d. CRC
56
© 2008 Pearson Education