Download Comp Prog 12 - Intro to Binary 1

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

List of first-order theories wikipedia , lookup

Algebra wikipedia , lookup

Addition wikipedia , lookup

Positional notation wikipedia , lookup

Location arithmetic wikipedia , lookup

Transcript
Computer Programming 12
Mr. Jean
February 5th, 2014
The plan:
• Video clip of the day
– http://www.youtube.com/watch?v=JjZNmhJ8X
u4
• Intro to Binary
• Intro to number systems
Introduction to Binary:
Binary
Base 2
x2
x2
8
1 or 0
x2
4
1 or 0
x2
2
1 or 0
1
1 or 0
Binary
Base 2
x2
x2
8
1
2
4
10
x2
4
x2
2
1
Binary
Base 2
x2
x2
x2
x2
8
4
2
1
1
0
0
0
1
2
0
0
1
0
4
0
1
0
0
10
1
0
1
0
Binary
Base 2
1
0001
2
0010
4
0100
10
1010
Binary
Base 2
x2
x2
8
x2
4
x2
2
1
Binary Digit = Bit
x2
x2
8
x2
4
x2
2
1
Binary
Base 2
x2
x2
128
64
x2
x2
32
16
Byte
x2
x2
8
4
x2
2
1
Introduction to Binary:
• Marble Counting Machine:
• http://www.youtube.com/watch?v=GcDsh
WmhF4A
• http://www.youtube.com/watch?v=md0TlSj
Iags
•KiloByte
•Megabyte
•Gigabyte
•TeraByte
512 256 128 64
1
1
1
1
1024 Bytes
1024 KiloBytes
1,048,576 Bytes
1024 MegaBytes
1,073,741,824 Bytes
1024 GigaBytes
1,099,511,627 ,776 Bytes
32
1
16
1
8
1
4 2 1
1 1 1
Binary Video:
• https://www.youtube.com/watch?v=ry1hp
m1GXVI
Practice for Adding in Binary:
1.
• Convert 20 to Binary
• Convert 12 to Binary
• Add the Two Binary Numbers together
2.
•
•
•
•
Convert 23 to Binary
Convert 31 to Binary
Add the Two Binary Numbers together
Find the Binary and decimal answer
How to find 59?
• My first step is to find the largest power of 2 that
is less than 59.
• 1, 2, 4, 8, 16, 32, 64.
Ok, 64 is larger than 59 so we take one step
back and get 32. 32 is the largest power of 2 that
is still smaller than 59.
• It can go in only once because 2 x 32 = 64 which
is larger than 59. So, we write down a 1.
• Now, we subtract 32 from 59: 59 – (1)(32)
= 27. And we move to the next lower
power of 2. In this case, that would be 16.
How many full times can 16 go into 27?
Once. So we write down another 1 and
repeat the process. 1
• 1
• 27 – (1)(16) = 11. The next lowest power of 2 is
8. How many full times can 8 go into 11? Once.
So we write down another 1.
• 111
• 11
• 11 – (1)(8) = 3. The next lowest power of 2 is 4.
How many full times can 4 go into 3? Zero. So,
we write down a 0.
• 1110
• 3 – (0)(4) = 3. The next lowest power of 2
is 2.
– How many full times can 2 go into 3?
– Once. So, we write down a 1.
• 11101
• 3 – (1)(2) = 1. And finally, the next lowest
power of 2 is 1. How many full times can 1
go into 1? Once. So, we write down a 1.
• 111011
To do:
• Complete the first side of the binary sheet
– Complete Questions 1 and 2
• Complete the “About Me” powerpoint
• Upcoming items:
– Correcting Binary sheet
– Adding and subtracting in binary