lesson4.1 u4 l1 binary representation

26
L.O: STUDENTS WILL UNDERSTAND AND USE BINARY REPRESENTATION . 30-60 minutes (1-2 class periods) DO NOW: what is the value of the following numbers? 0000, 0001, 0010, 0011, 1111, 10000?

Upload: lexume1

Post on 21-Feb-2017

21 views

Category:

Education


2 download

TRANSCRIPT

Page 1: Lesson4.1 u4 l1 binary representation

L.O: STUDENTS WILL UNDERSTAND AND USE

BINARY REPRESENTATION.30-60 minutes (1-2 class periods)

DO NOW: what is the value of the following numbers?

0000, 0001, 0010, 0011, 1111, 10000?

Page 2: Lesson4.1 u4 l1 binary representation

•0000 •0001 •0010 •0011 •1111 •10000

This is 0

This is 1

This is 2

This is 3

This is 15

This is 16

What is the value of each of these numbers?

Today, you will learn WHY and

HOW!

Page 3: Lesson4.1 u4 l1 binary representation

Have you ever seen this movie?What were the directors trying to show by filming scenes like this?

This is BINARY; the REAL “language” of computers!

Binary number is a representation of numbers using only two digits (0 and 1)

Page 4: Lesson4.1 u4 l1 binary representation

People typically work with DECIMAL numbers using the base

10 (decimal) numeral system…

other systems are relevant in

computer science,

including binary (base 2)

and hexadecimal

(base 16).

Computers manage data packed as sequences of bits (binary digits),

which are all zeros or ones.

People are most familiar with base 10, so we write software that allows people to

use base 10 to communicate with the computer.

Page 5: Lesson4.1 u4 l1 binary representation

In base 10, there are ten digits (0-9), and each place is worth ten times the

place to its right.

Page 6: Lesson4.1 u4 l1 binary representation

In binary, base 2, there are only two digits (0 and 1), and each place is worth

two times the place to its right.

The subscript 2 on 11012 means the 1101 is in base 2. Numbers are

normally written in base 10, so a subscript 10 is

only used when needed for clarity.

Page 7: Lesson4.1 u4 l1 binary representation

For You To Do: Watch this Binary Timer Snap! program run. Write a description of the binary

counter's behavior. Explain what you see going on.

Page 8: Lesson4.1 u4 l1 binary representation

base 10• In base 10 notation, each place value

represents a power of ten: the units place (100 = 1), the tens place (101 = 10), the hundreds place (102 = 100), the thousands place (103 = 1000), etc. So, for example:

9827 = 9 × 103 + 8 × 102 + 2 × 101 + 7 × 100

Page 9: Lesson4.1 u4 l1 binary representation

Reading Binary

• Base 2 uses the same idea but with powers of two instead of powers of ten. Binary place values represent the units place (20 = 1), the twos place (21 = 2), the fours place (22 = 4), the eights place (23 = 8), the sixteens place (24 = 16), etc. So, for example:

100102 = 1 × 24 + 0 × 23 + 0 × 22 + 1 × 21 + 0 × 20 = 16 + 2 = 1810

Page 10: Lesson4.1 u4 l1 binary representation

We will now watch a video on abstraction: numbers

https://youtu.be/SqhbDWVOLvk

Page 11: Lesson4.1 u4 l1 binary representation

Binary numbers are a form of abstraction because the 1’s and 0’s is the “language”

the computer understands.

Binary numbers are abstraction because when we use a computer, everything we do is

turned into the 1’s and 0’s of binary behind the “scenes”

Page 12: Lesson4.1 u4 l1 binary representation

How to turn binary (base 2) to decimals (base 10)

To translate from binary (like 1011012 ) to base 10, 1. first, write the number out on paper. 2. Then write out the binary place values by doubling left

from the units place:

1 0 1 1 0 132 16 8 4 2 1

This means this number is 32 + 8 + 4 + 1. So, 101101 2 = 4510

Page 13: Lesson4.1 u4 l1 binary representation

2. Translate these binary numerals into base 10 notation:

a.1012

b.1112

c.10100112

5

7

83

510

710

8310

Page 14: Lesson4.1 u4 l1 binary representation

Turning decimal into BinaryTo translate from base 10 (like 8910 to base 2,1. first write out the binary place values by doubling left

from the units place until you get to a value larger than your number. (256 for this example)

2. Then think, "My number is smaller than 128, so I can leave that place blank

3. But I can take out a 64, so I write a 1 there, and there's 25 left (89 – 64)

4. I have 0 thirty-twos, because I only have 25. But I can take out 16,

5. and there's 9 left. So, 8 and 1 are the last nonzero bits.

Page 15: Lesson4.1 u4 l1 binary representation

8925910

128 64 32 16 8 4 2 1

1 0 1 1 0 0 1

Now, read the number off: 10110012 = 8910

Page 16: Lesson4.1 u4 l1 binary representation

In mathematics and computer science,

an algorithm is a sequence of actions to be performed.

a. First, find the largest power of two that fits inside the number.

b. Then, subtract that power of 2 from the number, keep the new number, and record a 1 in the place for that power of 2.

Algorithms perform calculations, data processing

and/or automated tasks.

Here's an algorithm you can follow to find the base 2 representation of any base 10 integer:c. Then, determine if the next largest

power of 2 fits inside the new number, and:

• If it does, subtract that power of 2 from the number, keep the new number, and record a 1 in the place for that power of 2.

• If it doesn't, keep the same number, and record a 0 for that power of 2

d. Repeat this whole step with the next largest power of 2 until you

have a bit (1 or 0) for all the remaining places down to and

including the ones place (by which point you should have nothing left

of the original number).

The string of ones and zeros you have recorded

is the binary representation of your

original number.

Page 17: Lesson4.1 u4 l1 binary representation

Note: wikiHow shows another way to

change binary to decimals, with an explanation.

Page 18: Lesson4.1 u4 l1 binary representation

Next week, I’m going to have you make a BINARY TIMER using SNAP!

Page 19: Lesson4.1 u4 l1 binary representation

Independent assessment:Represent these base 10 numerals in binary (base 2):

a.63b.64c. 65d.129e.128f. 127

111111

1000000

1000001

10000001

10000000

1111111

a.6310 = 1111112

b.6410 = 10000002

c.6510 = 10000012

d.12910 = 100000012

e.12810 = 100000002

f.12710 = 11111112

Page 20: Lesson4.1 u4 l1 binary representation

Homework: complete the binary to

decimal/ decimal to binary work sheet

Page 21: Lesson4.1 u4 l1 binary representation

Learning Objectives:

• LO 2.1.1 Describe the variety of abstractions used to represent data. [P3]• LO 2.1.2 Explain how binary

sequences are used to represent digital data. [P5]

Page 22: Lesson4.1 u4 l1 binary representation

Enduring Understandings:

•EU 2.1 A variety of abstractions built upon binary sequences can be used to represent all digital data.

Page 23: Lesson4.1 u4 l1 binary representation

Essential Knowledge:

1. EK 2.1.1A Digital data is represented by abstractions at different levels.

2. EK 2.1.1B At the lowest level, all digital data are represented by bits.

3. EK 2.1.1C At a higher level, bits are grouped to represent abstractions, including but not limited to numbers, characters, and color.

4. EK 2.1.1D Number bases, including binary, decimal, and hexadecimal, are used to represent and investigate digital data

Page 24: Lesson4.1 u4 l1 binary representation

Essential Knowledge:• 5. EK 2.1.1E At one of the lowest levels of

abstraction, digital data is represented in binary (base 2) using only combinations of the digits zero and one.

• 6. EK 2.1.1F Hexadecimal (base 16) is used to represent digital data because hexadecimal representation uses fewer digits than binary.

• 7. EK 2.1.1G Numbers can be converted from any base to any other base.

• 8. EK 2.1.2A A finite representation is used to model the infinite mathematical concept of a number.

Page 25: Lesson4.1 u4 l1 binary representation

Essential Knowledge:

• 9. EK 2.1.2B In many programming languages, the fixed number of bits used to represent characters or integers limits the range of integer values and mathematical operations; this limitation can result in overflow or other errors.

• 10.EK 2.1.2C In many programming languages, the fixed number of bits used to represent real numbers (as floating point numbers) limits the range of floating point values and mathematical operations; this limitation can result in round off and other errors.

Page 26: Lesson4.1 u4 l1 binary representation

Essential Knowledge:• 11. EK 2.1.2D The interpretation of a binary sequence

depends on how it is used.• 12. EK 2.1.2E A sequence of bits may represent

instructions or data.• 13. EK 2.1.2F A sequence of bits may represent different

types of data in different contexts.• 14. EK 6.2.2J The bandwidth of a system is a measure of

bit rate—the amount of data (measured in bits) that can be sent in a fixed amount of time.

• 15. EK 6.2.2K The latency of a system is the time elapsed between the transmission and the receipt of a request.