Download presentation
Presentation is loading. Please wait.
1
Number Systems
2
Java Bits & Bytes Object Oriented Programming
The material in this chapter is not tested on the AP CS exams.
3
Bits & Bytes A bit (a contraction of binary digit) is the basic capacity of information in computing and telecommunications; a bit can have a value of either 1 or 0 (one or zero). You can think of a bit as a one digit binary number. The only possible values are 0 and 1.
4
Bits & Bytes In the world of digital computers a bit is an electronic switch that has two states – on or off. You can think of a bit as a one digit binary number. The only possible values are 0 and 1. It’s very similar to a light switch.
5
Bits & Bytes Since a bit can only represent two possible values (0 or 1) we combine bits into groups called bytes. You can think of a bit as a one digit binary number. The only possible values are 0 and 1. It’s very similar to a light switch.
6
Bits & Bytes A byte is comprised of 8 bits.
A byte is the basic addressable element in many computer architectures. You can think of a bit as a one digit binary number. The only possible values are 0 and 1. It’s very similar to a light switch.
7
Bits & Bytes A byte is comprised of 8 bits.
A byte is the basic addressable element in many computer architectures. 8 bits You can think of a bit as a one digit binary number. The only possible values are 0 and 1. It’s very similar to a light switch. _ _ _ _ _ _ _ _ byte
8
Bits & Bytes byte = 1 Binary 1 equals decimal 1.
9
Bits & Bytes 1 1 1 1 1 1 1 1 byte = 255 Binary 11111111 = 255.
= 255 Binary = 255. What if we want to work with numbers larger than 255? We need a different data type!
10
How Digital Computers Store Information
11
Digital Computers A What is this? The letter ‘A’.
12
01000001 Digital Computers What is this?
How a computer sees the letter ‘A’.
13
Digital Computers Computers are called digital devices because all of the information inside it is represented and manipulated as binary numbers. All of the numbers in a spreadsheet, all of the text characters in a Word document, all of the pictures and sounds stored in a computer, are ALL represented as binary numbers. The original meaning of “digit” is “finger” and since people often count using their fingers, the term digit also came to to be applied to numbers.
14
Digital Computers ‘A’ has a hexidecimal value of 41 – which is a decimal value of 65 – or a binary value of
15
Digital Computers The number system that you use is base 10. When you write the number 1853, for example it means: Why do we use a base 10 number system? Each digit (0-9) within a base 10 number is multiplied by the power of ten corresponding to its position. Notice that each digit place has 10 times the value of the digit place to the right of it. But you knew all this, of course.
16
Digital Computers Base10 is not convenient for a computer (which has no fingers) to use. What computers DO have, are electrical circuits, which are either on or off. Just two states to work with. So the natural number system for use in an electronic computer is base2 (called the binary number system). The original meaning of “digit” is “finger” and since people often count using their fingers, the term digit also came to to be applied to numbers.
17
Digital Computers In a computer’s memory, a tiny electronic switch that is on (conducting a current) might represent a 1, while that same switch that is off would represent a 0 (zero).
18
Digital Computers It gets cumbersome saying “binary digit” all the time, so the shorter term “bit” was invented. A bit is one binary digit. A bit can hold either a 1 or a 0 (zero). A string of bits can hold larger numbers (just as you use strings of base 10 digits to represent numbers larger than 9).
19
Digital Computers A particularly handy size chunk of computer memory happens to be 8 bits long. A byte can be used to represent any number from zero ( ) to 255 ( ). This is the basic unit we use to measure computer memory size.
20
Digital Computers A computer would store the value 181 in it’s binary form. 181 (base10) = (base2)
21
Decimal Number System
22
Decimal Number System 1 2 3 4 5 6 7 8 9 Now what?
1 2 3 4 5 6 7 8 9 Now what? We just ran out of numbers! Nine is the largest number in the base 10 system. What happens when you add 1 to 9?
23
Decimal Number System 1 2 3 4 5 6 7 8 9 10 We bring in a new digit!
1 2 3 4 5 6 7 8 9 We bring in a new digit! Nine is the largest number in the base 10 system. What happens when you add 1 to 9? 10
24
Binary Number System
25
Binary Number System 1 Now what? We just ran out of numbers!
1 Now what? We just ran out of numbers! Nine is the largest number in the base 10 system. What happens when you add 1 to 9?
26
Binary Number System 1 10 We bring in a new digit!
1 We bring in a new digit! 10 One is the largest number in the base 2 system. What happens when you add 1 to 1?
27
Decimal Binary Equivalency
28
Equivalent Values Every decimal number has an equivalent binary number and every binary number has an equivalent decimal value.
29
Equivalent Values Decimal Binary 1 2 10
30
Equivalent Values What do we get when we add 1 to a binary 10?
Decimal Binary 1 2 10 3
31
Equivalent Values Decimal Binary 1 2 10 3 11
32
Equivalent Values What do we get when we add 1 to a binary 11?
Decimal Binary 1 2 10 3 11 4
33
Equivalent Values Decimal Binary 1 2 10 3 11 4 11 +1
34
Equivalent Values Decimal Binary 1 2 10 3 11 4 11 +1 1 + 1 = 10
35
Equivalent Values Decimal Binary 1 2 10 3 11 4 1 11 +1 Carry the 1
36
Equivalent Values Decimal Binary 1 2 10 3 11 4 1 11 +1 100
1 2 10 3 11 4 1 11 +1 100 1 + 1 = 10. Bring down the 10.
37
Equivalent Values Decimal Binary 1 2 10 3 11 4 100
38
Equivalent Values Decimal Binary 1 2 10 3 11 4 100 5 101
39
Equivalent Values What do we get when we add 1 to a binary 101?
Decimal Binary 1 2 10 3 11 4 100 5 101 6
40
Equivalent Values Decimal Binary 1 2 10 3 11 4 100 5 101 6 110
41
Equivalent Values Decimal Binary 1 2 10 3 11 4 100 5 101 6 110 7 111
42
Equivalent Values What do we get when we add 1 to a binary 111?
Decimal Binary 1 2 10 3 11 4 100 5 101 6 110 7 111 8
43
Equivalent Values Decimal Binary 1 2 10 3 11 4 100 5 101 6 110 7 111 8
1 2 10 3 11 4 100 5 101 6 110 7 111 8 1000
44
Equivalent Values 1 2 10 4 100 8 1000 Do you see a pattern?
Decimal Binary 1 2 10 3 11 4 100 5 101 6 110 7 111 8 1000 Do you see a pattern?
45
Binary To Decimal Conversion
46
Binary To Decimal Conversion
1 128 64 32 16 8 4 2 Notice that each binary digit position in the base 2 number has 2 times the value of the binary digit position to the right of it (since this is base 2; remember how base 10 worked).
47
Binary To Decimal Conversion
1 128 64 32 16 8 4 2
48
Binary To Decimal Conversion
1 128 64 32 16 8 4 2
49
Binary To Decimal Conversion
1 128 64 32 16 8 4 2
50
Binary To Decimal Conversion
1 128 64 32 16 8 4 2
51
Binary To Decimal Conversion
1 128 64 32 16 8 4 2
52
Binary To Decimal Conversion
1 128 64 32 16 8 4 2
53
Binary To Decimal Conversion
1 128 64 32 16 8 4 2
54
Binary To Decimal Conversion
1 128 64 32 16 8 4 2
55
Binary To Decimal Conversion
1 128 64 32 16 8 4 2 181
56
Decimal To Binary Conversion
Take out a sheet of paper and a pen or a pencil.
57
Decimal To Binary Conversion
(base2) = ______ (base10) Solve the problem! Have students solve the problem on a sheet of paper and hold their answers up over their heads when done.
58
Decimal To Binary Conversion
= 25510
59
Decimal To Binary Conversion
60
Decimal To Binary Conversion
18110 = _____________2 181
61
Decimal To Binary Conversion
Divide the original number 181 by the base of the number you are converting it into – in this case 2. 181 / 2 is 90 with a remainder of 1. The 1 is a binary number. Division by 2 will always result in 0 or 1 as a remainder. 90 2 181 1
62
Decimal To Binary Conversion
45 Now divide 90 by 2. 90 / 2 is 45 with a remainder of 0. The 0 is a binary number. 2 90 181 1
63
Decimal To Binary Conversion
22 2 45 1 Now divide 45 by 2. 45 / 2 is 22 with a remainder of 1. The 1 is a binary number. 90 181 1
64
Decimal To Binary Conversion
11 2 22 45 1 Now divide 22 by 2. 22 / 2 is 11 with a remainder of 0. The 0 is a binary number. 90 181 1
65
Decimal To Binary Conversion
5 2 11 1 22 45 1 Now divide 11 by 2. 11 / 2 is 5 with a remainder of 1. The 1 is a binary number. 90 181 1
66
Decimal To Binary Conversion
2 2 5 1 11 1 22 45 1 Now divide 5 by 2. 5 / 2 is 2 with a remainder of 1. The 1 is a binary number. 90 181 1
67
Decimal To Binary Conversion
1 2 2 5 1 11 1 22 45 1 Now divide 2 by 2. 2 / 2 is 1 with a remainder of 0. The 0 is a binary number. Thus, = 90 181 1
68
Decimal To Binary Conversion
1 2 2 18110 = 5 1 11 1 22 45 1 Now divide 2 by 2. 2 / 2 is 1 with a remainder of 0. The 0 is a binary number. Thus, = 90 181 1
69
Decimal To Binary Conversion
Take out a sheet of paper and a pen or a pencil.
70
Decimal To Binary Conversion
77 (base10) = __________ (base2) Solve the problem! Have students solve the problem on a sheet of paper and hold their answers up over their heads when done.
71
Decimal To Binary Conversion
7710 =
72
Questions?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.