## Numbers and Computers

Consider cutting into two pages. --MF, 1/11/23
Next time around, we should add content to cover (maybe an extra page like 1.6.4, Emoji Deep Dive):

2-NI-05: Explain how physical and digital security measures protect electronic information. Information that is stored online is vulnerable to unwanted access. Examples of physical security measures to protect data include keeping passwords hidden, locking doors, making backup copies on external storage devices, and erasing a storage device before it is reused. Examples of digital security measures include secure router admin passwords, firewalls that limit access to private networks, and the use of a protocol such as HTTPS to ensure secure data transmission.

2-IC-23: Describe tradeoffs between allowing information to be public and keeping information private and secure. Sharing information online can help establish, maintain, and strengthen connections between people. For example, it allows artists and designers to display their talents and reach a broad audience. However, security attacks often start with personal information that is publicly available online. Social engineering is based on tricking people into revealing sensitive information and can be thwarted by being wary of attacks, such as phishing and spoofing.

--MF, 10/23/21
In this activity, you will learn how to use Snap! like a calculator and how computers store numbers.

### Crunching Numbers

Snap! can do calculations just like a calculator. You can even nest operations inside each other, and they will behave just like when you use parentheses in a math expression.

1. Open this Numbers Bits Electricity project, and save it to your account.
2. Build and run each of the following expressions:

Notice that for the expression , the first input to the block is the output of the block (that is, 100), so this expression means (20 × 5) / 4.

Similarly for the expression , the second input to the block is the output of the expression (that is, 25), so this expression means 28 - ((20 × 5) / 4). You can imagine the rounded corners of the blocks to be parentheses.

1. Build Snap! expressions to calculate the following:
55, 27
1. 5 × (7 + 4)
2. (11 – (48 / 6)) × 9
1. Build Snap! expressions to calculate the following:
239, 10
1. (2 × (10^2)) + (3 × (10^1)) + (9 × (10^0))
2. (1 × (2^3)) + (0 × (2^2)) + (1 × (2^1)) + (0 × (2^0))

### Numbers Systems for Humans vs. Machines

CSP treatment of binary

The numbers you use in daily life are decimal numerals.

: Decimal Numerals

A decimal numeral is part of the base 10 system, the system we learn by counting on ten fingers.

In base 10, there are ten digits (0-9), and each place is worth ten times as much as the place to its right.

For example, consider the number 239...

2
3
9
100s place
10s place
1s place

The number 239 is equal to (2 × 100) + (3 × 10) + (9 × 1). You could write it in Snap! like this:
1. Describe each of the digits and their place values for the decimal numeral 2405.

Instead of counting on ten fingers, computers count with only two options: on and off. So, computers store numbers as binary numerals. All their calculations are in binary. They convert the decimal numerals we use to interact with computers into binary numerals before performing any calculations.

: Binary Numerals

A binary numeral is part of the base 2 system.

In base 2, there are two digits (0-1), and each place is worth twice times as much as the place to its right.

For example, consider the binary numeral 1010...

1
0
1
0
8s place
4s place
2s place
1s place

We can figure out the decimal equivalent by adding up all the places that have a one (that is, 8 + 2 = 10). You could write it in Snap! like this:
1. 39
Find the decimal representation for the binary numeral 100111.