Click here to get the file
Download
Report
Transcript Click here to get the file
Chapter 2
Binary Values and
Number Systems
- Eswari Manickam
Materials are from text book with additions and
adaptations by Eswari Manickam
Chapter Goals
•
•
•
•
Distinguish among categories of numbers
Describe positional notation
Convert numbers in other bases to base 10
Convert base-10 numbers to numbers in other
bases
• Describe the relationship between bases 2 and
16
• Explain the importance to computing of bases
that are powers of 2
2
24
6
Binary
Decimal is base 10 and has 10 digits:
0,1,2,3,4,5,6,7,8,9
Binary is base 2 and has 2 digits:
0,1
For a number to exist in a given base, it can only contain the
digits in that base, which range from 0 up to (but not including)
the base.
What bases can these numbers be in? 122, 198, 178, G1A4
3
9
Positional Notation
• 642 is 600 + 40 + 2 in BASE 10
Continuing with our example…
642 in base 10 positional notation is:
6 x 102 = 6 x 100 = 600
+ 4 x 101 = 4 x 10 = 40
+ 2 x 10º = 2 x 1 = 2
= 642 in base 10
4
Converting Binary to Decimal
What is the decimal equivalent of the binary
number 1101110?
1 x 26
+ 1 x 25
+ 0 x 24
+ 1 x 23
+ 1 x 22
+ 1 x 21
+ 0 x 2º
5
=
=
=
=
=
=
=
1 x 64
1 x 32
0 x 16
1x8
1x4
1x2
0x1
= 64
= 32
=0
=8
=4
=2
=0
= 110 in base 10
13
Converting Binary to Decimal
What is the decimal equivalent of the
following binary numbers?
a) 11101
b) 1011010
c) 10011100
6
Bases Higher than 10
How are digits in bases higher than 10
represented?
With distinct symbols for 10 and above.
Hexadecimal is base 16 and has 16 digits:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E, and F
7
10
Converting Hexadecimal to Decimal
What is the decimal equivalent of the
hexadecimal number 32A?
3 x 162 = 3 x 256 = 768
+ 2 x 161 = 3 x 16 = 48
+ A x 16º = 10 x 1 = 10
= 826 in base 10
Remember, the digits in base 16 are
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
8
Converting Hexadecimal to Decimal
What is the decimal equivalent of the
following hexadecimal numbers?
a) 87A
b) 34E
c) F000
9
Counting in Binary/Hexadecimal/Decimal
10
Decimal
Hexadecimal
Binary
0
0
0000
1
1
0001
2
2
0010
3
3
0011
4
4
0100
5
5
0101
6
6
0110
7
7
0111
8
8
1000
9
9
1001
10
A
1010
11
B
1011
12
C
1100
13
D
1101
14
E
1110
15
F
1111
Converting Binary to Hexadecimal
• Mark groups of four (from right)
• Convert each group
10101011
1010 1011
A
B
10101011 is AB in base 16
11
18
Converting Binary to Hexadecimal
What is the hexadecimal equivalent of the following
binary numbers?
• 00001001
• 10101001
• 010111011110
12
Converting Decimal to Other Bases
Algorithm for converting number in base
10 to other bases
While (the quotient is not zero)
Divide the decimal number by the new base
Make the remainder the next digit to the left in
the answer
Replace the original decimal number with the
quotient
13
19
Converting Decimal to Hexadecimal
What is the hexadecimal equivalent of (3567) ?
10
222
16 3567
32
36
32
47
32
15
13
16 222
16
62
48
14
0
16 13
0
13
DEF
14
21
Converting Decimal to Hexadecimal
What is 356 (base 10) in base 16?
What is 1135 (base 10) in base 16?
What is 4759 (base 10) in base 16?
Try it!
15
20
Converting Decimal to Binary
Example of converting decimal to binary
What is the binary equivalent of the decimal number 35?
17
8
4
2 35 2 17 2 8
34
16
8
1
1
0
2
4
4
0
1 0
2 1
2 0
0 1
Adding digits to the left as we calculate:
100011
16
Converting Decimal to Binary
Easy method for converting decimal to binary
What is the binary equivalent of the decimal number 35?
2 35 - 1
2 17 - 1
2 8 - 0
2 4 - 0
2 2 - 0
2 1 - 1
0
17
So reading from the bottom – The answer would be
100011
Converting Decimal to Binary
What is the binary equivalent of the following decimal
integers?
A) 64
B) 1066
C) 213
D) 1790
18
Arithmetic in Binary
Remember that there are only 2 digits in binary,
0 and 1
1 + 1 is 0 with a carry
111111
1010111
+1 0 0 1 0 1 1
10100010
19
Carry Values
14
Arithmetic in Binary
Calculate:
a) 10001 + 11101
b) 1110 + 1111
c) 1011001 + 111010
20
Subtracting Binary Numbers
Remember borrowing? Apply that concept
here:
12
202
1010111
- 111011
0011100
21
15
Subtracting Binary Numbers
Calculate:
A) 1011011 - 10010
B) 1010110 - 101010
C) 1000101 - 101100
22
Binary Numbers and Computers
Computers have storage units called binary digits or
bits
Low Voltage = 0
High Voltage = 1
23
all bits have 0 or 1
22
Binary and Computers
Byte
8 bits
The number of bits in a word determines the word
length of the computer, but it is usually a multiple
of 8
• 32-bit machines
• 64-bit machines etc.
24
23