Eric Evans – Planboard Lesson – Mar 22 2018 Computer Science 2

# Category: UIL Computer Science

## CS2 20-Mar-2018

## Number Conversions from Base 10

I have written a few posts (Post 1, Post 2, & Post 3) concerning various base number systems. In all of these posts, I covered how to convert from a non-decimal base into a decimal base. In other words, I covered how to get INTO base-10. This post is going to cover the inverse (decimal base into non-decimal base).

#### Modulus

We will need to start by reviewing the concept of modulus division. Let’s look at the standard division problem 5/2. We would typically say that the answer is 2.5 and this would be correct.

Now, modulus is simply the remainder of a division problem. Go back to when you were first introduced to division. In Texas, this is typically in 4th grade. Let’s take a look at that division problem of 5/2 again. When you were learning division, you would have said the answer was 2r1. The 1 is the modulus. When we’re writing the problem to just solve modulus, we would write it as 5%2.

#### Mechanics

##### Decimal to Octal

Let’s say that we have the decimal number (base 10) 4,814 and we want to convert it to an octal (base 8).

We will be building the number from right-to-left. The first thing we will do is solve 4,814/8. This equals 601r6. So, our first digit of the solution (starting on the right) is 6.

6

Now, we solve 601/8, which equals 75r1. So, our second digit of the solution (floating from right-to-left) is 1.

16

Now, we solve 75/8, which equals 9r3. So, our third digit of the solution (floating from right-to-left) is 3.

316

Now, we solve 9/8, which equals 1r1. So, out fourth digit of the solution (floating from right-to-left) is 1.

1316

Finally, we solve 1/8, which equals 0r1. So, our fifth and final digit of the solution (floating from right-to-left) is 1.

11316

So, the decimal number (base 10) 4,814 is equal to the octal (base 8) 11316.

As you can see, this is a bit of a process, but once you know the process, it is very simple. I now want to take a look at going to number systems with more digits than base 10, for example: base 16.

##### Decimal to Hexadecimal

Let’s say that we have the decimal number (base 10) 4,814 and we want to convert it to a HEX (base 16).

We start by solving 4,814/16, which gives us 300r14. Remember, that is number systems with more than 10 digits, we start using letters.

10 = A

11 = B

12 = C

13 = D

14 = E

15 = F

So, the first digit of our solution (building from right-to-left) is E.

E

Now, we solve 300/16, which gives us 18r12. So, the second digit of our solutions (building from right-to-left) is C.

CE

Now, we solve 18/16, which gives us 1r2. So, the third digit of our solution (building from right-to-left) is 2.

2CE

Finally, we solve 1/16, which gives us 0r1. So, the fourth digit of our solution (building from right-to-left) is 1.

12CE

So, the decimal number (base 10) 4,814 is equal to the hexadecimal (base 16) 12CE.

## 2016-2017 Year In Review

Well, here I am – the last day of the 2016-2017 school year. It’s been a great ride this year.

##### June 2016

I had the experience of attending my first Advanced Placement Summer Institute! This was to prepare us for AP Computer Science Principles (AP Computer Science I).

This particular APSI was different from others in that it was not run by College Board, but by the UTeach Institute at University of Texas through the National Science Foundation.

##### July 2016

After learning about Computer Science in June, I shifted gears to learn about FIRST Robotics. I got to attend a week-long hands-on workshop with Freid Elliott of Dallas ISD and Dr. Patrick Michaud of University of Texas: Dallas.

This training was invaluable in preparing me for the launch of our new robotics program at Ferris High School. Without this workshop, I couldn’t even guess as to how long it would have taken us to get our robot moving.

##### August 2016

For the first time since August 2012, I had the opportunity to start a school year in a high school! I was very happy to be returning to high school for a full-year.

In August of 2013 and August 2014, I was teaching at The Art Institute of Dallas and in August 2015, I was teaching 4th grade at Ferris Intermediate School.

This year, I taught 1 section of Computer Science, 1 section of Robotics & Automation, 1 section of Principles of Technology/Physics, and 4 sections of Business Information Management (BIM).

##### September 2016

Now that the school-year was fully underway, I got started on teaching material.

In Computer Science, we hit the ground running with programming in JAVA. In Principles of Technology, we built pressurized soda-bottle rockets and launched them!

In Robotics & Automation, we had the reveal of the game for the 2016/2017 season – Velocity Vortex! It was exciting to see the gears turning as my students started planning how to address the challenge of the game for this year. They were very excited to start designing and building the robot for the game!

My robotics class had the opportunity to work on the Finch robots that were loaned to us from Carnegie Mellon University.

##### October 2016

Now that we knew the game for robotics, we started having “Come As You Can” (CAYC) workdays on Saturdays for students to come up to the high school and work on the robot.

Here, students were encouraged to come up to the high school to work on the contest robot. I would have the lab open and it was a self-paced workday. Each CAYC workday was typically 8 to 12 hours.

In addition to the robotics CAYC workdays, I had fun with my Principles of Technology class with an egg drop experiment. Here, they had to create a rig that could cushion the fall of a raw egg dropped from a considerable height.

There were 3 rigs that no matter the height, the egg survived again and again. I was very pleased. In the follow-up, the groups had to calculate the force their rig struck the ground with.

##### November 2016

The robotics team did the majority of their hardware work during this month. This was the month that we got the robot moving!

This was also when we had our only season scrimmage for robotics.

This was our first experience with one of the guiding principles of FIRST Robotics – “Coopertition”. This is the idea of cooperative competition. While this was a scrimmage in that we were able to see what the robots of others teams were able to do, it was also a workshop for us to be able to refine our skills and the build of our robot.

During this month, Principles of Technology worked on creating mouse trap racers.

They had the chance to demonstrate their ability to mix-and-match parts to maximize their designs.

The parts for this project were donated from Donors Choose over the summer in preparation for the school year.

##### December 2016

As we began to wind-down the 2016 calendar year, the robotics team arrived at their first of 3 league meets which was hosted at Ferris High School.

The robotics team performed very well in their first outing and assumed 2nd place in the season standings. This was an outstanding way to start our inaugural season of FIRST Tech Challenge robotics!

UIL Computer Science also kicked off this month with its first virtual meet. Back in the 2015/2016 academic year, the UIL Computer Science team advanced on its own to UIL Regional competition as a student-run after-school club!

##### January 2017

This month saw two robotics league meets. Both of these meets were at Mansfield Ben Barber Innovation Academy.

In addition, between the two league meets, the robotics team presented at Ferris Intermediate School addressing the disproportionate representation of girls in STEM fields.

The various members of the robotics team had an enjoyable time working with the students at FIS!

##### February 2017

This month was really “hot” in multiple ways. The robotics team hosted the league tournament at Ferris High School.

ERROR 404, the FHS robotics team, entered the tournament in 4th place and by the end of the day was solidly in 3rd place.

The team performed very well and had a strong alliance partner as they advanced into the elimination round of the tournament. Unfortunately, we saw the season come to an end in the blink of an eye when a spectator turned on a WiFi hotspot on their phone, which caused our robot to stop.

The Tuesday following the league meet, the month got even hotter when an experiment in my Principles of Technology class went very wrong!

Just 4 days after that fire, the Computer Science team performed in its only face-to-face invitational meet in Mabank. The team from Ferris High School finished in 1st place at the invite!

##### March 2017

As robotics shifted into off-season mode, and I was looking to regain footing by retooling some experiments in Principles of Technology, March was all about Computer Science.

In late-March, the UIL Computer Science team competed in the UIL District Tournament where they finished in 1st place and advanced to the UIL Regional Tournament!

I was extremely proud of how our team captain performed at this tournament and his decision to hand over the reins to his successor so she could gain some experience in the role she has shadowed for the past two seasons.

##### April 2017

As we had “played with fire” in February in Principles of Technology, I elected that water would be much safer for us to play with.

So, in mid-April, Principles of Technology built water balloon launchers and launched to strike targets at 20, 40, and 50 yards. To make this more fun, the targets were Mr. Mack McClesky (FHS Assistant Principal), myself, and Dr. Kevin Dixon (FHS Principal) respectively.

Students had to calculate maximum range, height, and launch angles in this experiment!

In addition to getting soaked, this month was also the UIL Computer Science team appearance at the UIL Regional Tournament at Texas A&M University: Commerce.

The UIL Computer Science team had a bit of a rough performance at the UIL Regional Tournament. I believe this was in-part due to over-preparing.

I appreciated with enthusiasm of the team members, but I think they over-worked themselves and succumbed to “brain drain” and fatigue ultimately did them in and they were just overwhelmed with information as they went into the test.

While we did not perform as well on the written test, the team demonstrated outstanding growth on the hands-on test. In 2015/2016, the team solved no hands-on problems at the UIL Regional Tournament. In contrast, the team solved 3 hands-on problems at the UIL Regional Tournament in 2016/2017!

On a personal note, April was when I said “Goodbye” to my home of 9 years in Forney.

For two of my children, this is the only house they really remember. Over the past several years, we have seen Forney grow from a semi-rural community to a suburban community where possessions and materialism have taken over and you are solely based upon what you have and how much you have.

We elected to move to the community where I teach in and where my oldest daughter elected to attend junior high at – Ferris.

It was a bit of a shift to go from a home that we built and was only 10 years old to a home that is over 100 years old. Our new home was built in 1894 and is now 123 years old! The pace of life in this community is wonderful and I would not go back to the suburban rush ever again, if I can have any say in it!

##### May 2017

Now, we have come full-circle. It has been a year! Both Robotics and Computer Science are in off-season mode and preparing for next year.

Principles of Technology finished the year with a project similar to the one we started the year with, using the 2-liter soda bottles. Unlike the project at the start of the year, students had to create an air foil to achieve non-projectile motion flight with the thrust provided by the pressurized 2-liter soda bottle.

I am looking forward to seeing my graduates walk across that stage and close one chapter in their lives and open the next new chapter! I am excited to hear how they continue to mature, grow, and develop.

I am very excited to see the programs and teams that were launched this year continue to develop next year.

In 2017/2018, we will be launching 2 new engineering courses:

- Principles of Applied Engineering
- Engineering Design & Problem Solving

In addition to those two new courses, we will be streamlining the robotics courses:

- Robotics I
- Robotics II

We will also be expanding our Computer Science program:

- Computer Science I (based on AP Computer Science Principles)
- Computer Science II (based on AP Computer Science – A)

I am extremely blessed to work for a school district and on a campus that supports my out-of-the-box teaching style and methods. I look forward to continuing to work in Ferris and with the children of this community.

## Base 2, 8, 10, & 16 Numbering

We are starting the UIL Computer Science season by looking at 4 major numbering systems. We are looking at the Base-2 (binary), Base-8 (octal), Base-10 (decimal), and Base-16 (hexadecimal) numbering systems.

### Base-10

Base-10 is also known as * decimal *or abbreviated to

*.*

**dec**This system is comprised of 10 unique digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.

The decimal numbering system is arguably the easiest numbering system since it is what we are the most familiar with.

In the decimal numbering system, numbers are read from left-to right, but the place-values run from right-to-left. Each place-value position is 10 times larger than the position to its right.

Let’s examine the decimal number 1,222_{10}

In this case, the 2 that is in the tens place is 10 times larger than the 2 that is in the ones place.

The 2 that is in the hundreds place is 10 times larger than the 2 that is in the tens place and 100 times larger than the 2 in the ones place.

The decimal numbering system working in multiples and fractions of 10.

### Base 2

Base-2 is also known as ** binary **or abbreviated to

**.**

*bin*This system is comprised of 2 unique digits: 0 and 1.

Binary numbers are read from left-to-right like decimal numbers and the place-values run from right-to-left.

Place Value Position |
0_{2} = Base-10 Value |
1_{2} = Base-10 Value |

1 | 0_{10} |
1_{10} |

2 | 0_{10} |
2_{10} |

3 | 0_{10} |
4_{10} |

4 | 0_{10} |
8_{10} |

5 | 0_{10} |
16_{10} |

6 | 0_{10} |
32_{10} |

7 | 0_{10} |
64_{10} |

8 | 0_{10} |
128_{10} |

Let’s look at the following binary number: 101_{2}

When reading from right-to-left, the first place value holds a 1_{2} and has a Base-10 value of 1_{10}.

The second place value holds a 0_{2} and has a Base-10 value of 0_{10}.

The third place value holds a 1_{2} and had a Base-10 value of 4_{10}.

To calculate the Base-10 value, we add the values of each place value together (1_{10} + 0_{10} + 4_{10}). In this case, the binary number 101_{2} has a Base-10 value of 5_{10}.

Let’s take a look at another binary number: 10011101_{2}

- Place Value 1 – 1
_{2}= Base-10 Value = 1_{10} - Place Value 2 – 0
_{2}= Base-10 Value = 0_{10} - Place Value 3 – 1
_{2}= Base-10 Value = 4_{10} - Place Value 4 – 1
_{2}= Base-10 Value = 8_{10} - Place Value 5 – 1
_{2}= Base-10 Value = 16_{10} - Place Value 6 – 0
_{2}= Base-10 Value = 0_{10} - Place Value 7 – 0
_{2}= Base-10 Value = 0_{10} - Place Value 8 – 1
_{2}= Base-10 Value = 128_{10}

Add all of the Base-10 values together (128_{10} + 16_{10} + 8_{10} + 4_{10} + 1_{10}) and we get 157_{10}. So, in this case, the binary number 10011101_{2} has a Base-10 value of 157_{10}.

### Base-8

Base-8 is also known as ** octal **or abbreviated to

**.**

*oct*This system is comprised of 8 unique digits: 0, 1, 2, 3, 4, 5, 6, and 7.

Octal numbers are read from left-to-right, like Base-10 numbers but we must read the place-value position from right-to-left, like Base-2 numbers.

Let’s examine the octal 2561_{8}.

(2_{8} X 8^{3}) + (5_{8} X 8^{2}) + (6_{8} X 8^{1}) + (1_{8} X 8^{0})

1024_{10} + 320_{10} + 48_{10} + 1_{10} = 1,393_{10}

So, the octal 2561_{8} has a Base-10 value of 1,393_{10}.

In the solution, note the first digit in each set of parenthesis corresponds to the digits in the octal (2, 5, 6, and 1). We multiplied each of those by 8 raised to the power of their position in the octal from right-to-left with the first position having a power of 0.

### Base 16

Base-16 is also known as ** hexadecimal **or abbreviated to

**.**

*hex*This system is comprised of 16 unique digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F.

Hexadecimal numbers can be written one of two ways and either way is considered acceptable.

**Method 1:** 2AF3_{16}

**Method 2:** 0x2AF3

To convert a hexadecimal to Base-10 is very similar to the process for converting an octal to Base-10.

Let’s examine the hex 2AF3_{16 }

(2_{16} X 16^{3}) + (A_{16} X 16^{2}) + (F_{16} X 16^{1}) + (3_{16} X 16^{0})

Before we can continue, we need to discuss the Base-10 equivalents of the hexadecimal digits.

- 0
_{16}= 0_{10} - 1
_{16}= 1_{10} - 2
_{16}= 2_{10} - 3
_{16}= 3_{10} - 4
_{16}= 4_{10} - 5
_{16}= 5_{10} - 6
_{16}= 6_{10} - 7
_{16}= 7_{10} - 8
_{16}= 8_{10} - 9
_{16}= 9_{10} - A
_{16}= 10_{10} - B
_{16}= 11_{10} - C
_{16}= 12_{10} - D
_{16}= 13_{10} - E
_{16}= 14_{10} - F
_{16}= 15_{10}

Now, we can continue:

(2_{16} X 16^{3}) + (A_{16} X 16^{2}) + (F_{16} X 16^{1}) + (3_{16} X 16^{0})

(2_{10} X 16^{3}) + (10_{10} X 16^{2}) + (15_{10} X 16^{1}) + (3_{10} X 16^{0})

8,192_{10} + 2,560_{10} + 240_{10} + 3_{10} = 10,995_{10}

### Where Are They Used?

**Base-10** is used as our standard counting and arithmetic system of the world around us. While it works great for our natural purposes, it does not lend itself to adequate use for internal processes of computer applications.

**Base-2** is used as the fundamental basis of computing and boolean logic. Since Base-2 only has 2 digits this can equate to yes/no, on/off, true/false and any other absolute polar response query.

**Base-8** is used in computer systems that parse 12-bit, 24-bit, and 36-bit binary words. Many of these computer systems are no longer in use and have been replaced with 32-bit and 64-bit binary word systems. As such, octal-based computing is no longer considered an efficient way to process data.

**Base-16** is used to represent numerical data in a more concise manner for programming purposes that isn’t as fundamental as Base-2.

An example is the HEX color system. Let’s look at the HEX color 9FBDDF_{16}. HEX colors are broken into 3 parts (1st 2 character represent amount of red, 2nd 2 characters represent amount of green, and 3rd 2 characters represent the amount of blue).

9F_{16} is the amount of red in the color. BD_{16} is the amount of green in the color. DF_{16} is the amount of blue in the color.

- In this example, we have 9F
_{16}equal to 159_{10}. - If we continue, we have BD
_{16}equal to 189_{10}. - Finally, we have DF
_{16}equal to 223_{10}.

It is much easier for a programmer to enter the following:

background-color: #9FBDDF;

as compared to:

background-color: rgb(159, 189, 223);