Lesson Plan. Preparation

Similar documents
Level ISA3: Information Representation

CS & IT Conversions. Magnitude 10,000 1,

Watkins Mill High School. Algebra 2. Math Challenge

The. Binary. Number System

Name: Date: Review Packet: Unit 1 The Number System

1.1 Review of Place Value

Pre Algebra 2. Student Goals. Curriculum Sample

Common Core State Standards Mathematics (Subset K-5 Counting and Cardinality, Operations and Algebraic Thinking, Number and Operations in Base 10)

Adding and Subtracting with Decimals

Number Systems CHAPTER Positional Number Systems

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

Chapter 2 Exercises and Answers

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

Chapter 1 Operations With Numbers

COMP Overview of Tutorial #2

Integers and Rational Numbers

Summer Assignment Glossary

5th Grade Mathematics Mathematics CC

TOPIC: NUMBER SYSTEMS

Algebra Homework: Chapter 1 (Homework is listed by date assigned; homework is due the following class period) Day Date In-Class Homework

Unit 3: Multiplication and Division Reference Guide pages x 7 = 392 factors: 56, 7 product 392

Review of Data Representation & Binary Operations Dhananjai M. Rao CSA Department Miami University

DIGITAL SYSTEM DESIGN

Lesson Plan. Course Title: Principles of Information Technology Session Title: Intro to Databases Lesson Duration: Varies dependent upon instructor

Chapter 1: Foundations for Algebra

Appendix 2 Number Representations

Chapter 2. Data Representation in Computer Systems

Gateway Regional School District VERTICAL ALIGNMENT OF MATHEMATICS STANDARDS Grades 3-6

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

SUMMER REVIEW PACKET 2 FOR STUDENTS ENTERING ALGEBRA 1

HOW TO DIVIDE: MCC6.NS.2 Fluently divide multi-digit numbers using the standard algorithm. WORD DEFINITION IN YOUR WORDS EXAMPLE

6-8 Math Adding and Subtracting Polynomials Lesson Objective: Subobjective 1: Subobjective 2:

Introduction to Numbering Systems

Chapter Binary Representation of Numbers

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Fraction to Percents Change the fraction to a decimal (see above) and then change the decimal to a percent (see above).

Rational Number is a number that can be written as a quotient of two integers. DECIMALS are special fractions whose denominators are powers of 10.

DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

Unit 2: Accentuate the Negative Name:

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Chapter 2 Bits, Data Types, and Operations

Module 1: Information Representation I -- Number Systems

CHW 261: Logic Design

Divide: Paper & Pencil

Decimals. Chapter Five

Math Glossary Numbers and Arithmetic

Algebra 2 Semester 1 (#2221)

Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

Number System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value

DECIMALS are special fractions whose denominators are powers of 10.

Computer Number Systems Supplement

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer.

Chapter 1 Preliminaries

Digital Logic Circuits Volume I Digital Number Systems

Chapter 4 Section 2 Operations on Decimals

Lesson Plan -- Multiplying and Dividing Integers

The type of all data used in a C++ program must be specified

Objectives. Connecting with Computer Science 2

LECTURE 1-2. Introduction and Number Systems

Arithmetic and Bitwise Operations on Binary Data

History of Computing. Ahmed Sallam 11/28/2014 1

Project 2: How Parentheses and the Order of Operations Impose Structure on Expressions

EE292: Fundamentals of ECE

Lesson Plan. Course Title: Digital Interactive Media Session Title: Master Pages

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Basic Operations and Equivalent Expressions - Step-by-Step Lesson

UNIT 6 OPERATIONS WITH DECIMALS

Algebra 1 Review. Properties of Real Numbers. Algebraic Expressions

Number Systems Using and Converting Between Decimal, Binary, Octal and Hexadecimal Number Systems

What Is It? Instruction Register Address Register Data Register

Name Period Date. REAL NUMBER SYSTEM Student Pages for Packet 3: Operations with Real Numbers

Module 2: Computer Arithmetic

Table of Contents. Introduction to the Math Practice Series...iv Common Mathematics Symbols and Terms...1

Calculations with Sig Figs

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

QUIZ: Generations of computer technology. Hardware:

Introduction to TURING

Read this before starting!

MAT 003 Brian Killough s Instructor Notes Saint Leo University

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

Lesson 1: Arithmetic Review

Algebra 2 Common Core Summer Skills Packet

Objective 1.02 Understand Numbering Systems

Basic Arithmetic Operations

Solving Equations with Inverse Operations

KNOWLEDGE OF NUMBER SENSE, CONCEPTS, AND OPERATIONS

9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Bits, Words, and Integers

PRE-ALGEBRA PREP. Textbook: The University of Chicago School Mathematics Project. Transition Mathematics, Second Edition, Prentice-Hall, Inc., 2002.

Lesson 1: Arithmetic Review

LESSON TITLE. Language English Local Language Introduction to Computer Science. Mr. VAR Sovannrath Submission Date October 30th, 2014 Version 1.

Exponents and Real Numbers

Chapter 4. Operations on Data

add and subtract whole numbers with more than 4 digits, including using formal written methods (columnar addition and subtraction)

Unit 3. Operators. School of Science and Technology INTRODUCTION

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

Read this before starting!

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Transcription:

Math Practicum in Information Technology Lesson Plan Performance Objective Upon completion of this lesson, each student will be able to convert between different numbering systems and correctly write mathematical formulas for use in computer programs. Specific Objectives Students will explain the concept of binary. Students will convert numbers between binary and decimal. Students will explain the concept of hexadecimal. Students will convert numbers between hexadecimal, binary, and decimal. Students will solve and write equations as utilized in computer programming. This lesson should take 10-1 class days to complete. Preparation TEKS Correlations This lesson, as published, correlates to the following TEKS. Any changes/alterations to the activities may result in the elimination of any or all of the TEKS listed. Practicum in Information Technology 130.80 (c) (3) The student applies academic knowledge and skills to research and develop projects. The student is expected to: (B) demonstrate proper use of mathematics concepts in the development of products or services; and (C) demonstrate proper use of science principles in the development of products or services. Interdisciplinary Correlations Reading I, II, III 110.47(b) (1) The student uses the following word recognition strategies. The student is expected to: (A) Apply knowledge of letter-sound correspondences, language structure, and context to recognize words; 1

(B) Use reference guides such as dictionaries, glossaries, and available technology to determine pronunciations of unfamiliar words; () The student acquires an extensive vocabulary through reading and systemic word study. The student is expected to: (A) Expand vocabulary by reading, viewing, listening, and discussing; (B) Determine word meanings through the study of their relationships to other words and concepts such as content, synonyms, antonyms, and analogies; (4) The student comprehends text using effective strategies. The student is expected to: (A) Use prior knowledge and experience to comprehend; (B) Determine and adjust purpose for reading; and (D) Summarize texts by identifying main ideas and relevant details. Public Speaking I, II, III 110.57 (b) (4) Organization. The student organizes speeches. The student is expected to: (B) Organize speeches effectively for specific topics, purposes, audiences, and occasions. (7) Delivery. The student uses appropriate strategies for rehearsing and presenting speeches. The student is expected to: (C) Develop verbal, vocal, and physical skills to enhance presentations. Tasks Students will utilize provided notes and slide presentation to complete notes pages. Students will complete worksheets. Accommodations for Learning Differences It is important that lessons accommodate the needs of every learner. These lessons may be modified to accommodate your students with learning differences by referring to the files found on the Special Populations page of this website (cte.unt.edu). Preparation Copy the handouts. Have multimedia presentations ready to show the class. Instructional Aids Student Notes sheet Student worksheets Materials Needed Copies Pencils

Equipment Needed Teacher computer Projector (for slide presentation) Introduction Learner Preparation Review slides 1-6 of the multimedia presentation with the class (positional numbering systems - specifically decimal). Lesson Introduction Ask the class: o How is data represented within a computer system? o How would information be more readable or user friendly for programmers and technicians? Tell the class that every character and command given to a computer by a user is translated into binary before it can be sent to the CPU for processing. Explain that in-depth computer troubleshooting and programming requires a firm understanding of numbering systems and how to convert between them. 3

Outline MI OUTLINE Slides 1 6 Decimal Review a. Natural numbers b. Integers c. Positional numbering system d. Number base e. Review of exponent laws regarding 0 and 1 st power f. Review positional numbering system a. Hundreds b. Tens c. Ones Slides 8 11 Converting from binary to decimal Slides 9 16 Converting from decimal to binary Slides 17 Introduction to hexadecimal Conversion from hexadecimal to binary Slides 3 6 Conversion from decimal to hexadecimal Slides 7 31 Rewriting math in programming Slides 3 36 Using math in programming NOTES TO TEACHER Extension notes are provided in the multimedia presentation. Timeline of delivery is at discretion of instructor. Guidelines regarding division of information are suggestions only. Upon completion of Slide 11, give students the binary to decimal conversion worksheet. Upon completion of Slide 16, give students the decimal to binary worksheet. Upon completion of Slide, give students the hexadecimal to binary worksheet. Upon completion of Slide 6, give students the decimal to hexadecimal worksheet. Upon completion of Slide 31, give students the evaluation of expressions worksheet. Upon completion of Slide 36, give students the worksheet on using programs to write and solve mathematical formulas worksheet. Multiple Intelligences Guide Existentialist Interpersonal Intrapersonal Kinesthetic/ Bodily Logical/ Mathematical Musical/Rhythmic Naturalist Verbal/Linguistic Visual/Spatial 4

Application Guided Practice Students will use the provided slide presentation to complete the notes handouts pages. Independent Practice Students will complete all provided worksheets: o Binary to decimal o Decimal to binary o Hexadecimal to binary o Decimal to hexadecimal o Rewriting math for computer programs o Using math in computer programs Summary Review Why is it important to know how to use math properly? What is the fundamental language of computers? Why was binary chosen as machine language? Evaluation Informal Evaluation The teacher will check frequently for understanding Very small work group option (peer tutoring) Formal Evaluation Worksheets and test over the material 5

Binary, Hex, and Decimal, Oh My! Student Notes Handout a. numbers a. Zero and any number obtained by repeatedly adding one to it b. Ex. 0, 1, 3, 100 b. Integers a. Any number b. Includes negative numbers and zero c. Numbering System a. The number depends on the position of the digits to represent the number. d. Number base a. The (or radix) is the number of digits used to represent numbers in a positional numerical system. Any number to the power is equal to 1. Example: 0 = Any number to the power is equal to that. Example: 1 = 6

Converting from Decimal to Binary Base The base of a number is indicated by a value at the end of the number. If there is no subscript the base is assumed to be 10 (or decimal). Uses and Binary uses two as its base so each is equal to two to an exponent. Since we are using two single characters we use and as our two digits. Consider the binary number 00001110. Binary Table Do you see how each in value? This makes binary one of the easiest numbering systems to convert to decimal. Using basic addition, we can take any binary number and convert it to a decimal equivalent. As long as you memorize the pattern all you have to do is the value of the placeholders where a 1 appears. 7

Look at the table. In the top row you notice there are only zeros and ones. This one is a little easier for you by adding the table and colors. This is the number we are going to convert to decimal,. By looking down the chart you can see that we are going to use the following values:,, and because there are 1s in those placeholders. Note that red indicates which numbers we will use to convert to a decimal value. Using the formal method, we would transfer the digits to the blue box you see on the right of the slide. I like to use the vertical alignment to make things easier to read. We start with ; determine that there is a zero in that placeholder. What is the answer when you multiply any number by zero? Answer: Moving down the line we have zeros until we get to the place holder right? This placeholder has a instead of a zero., which is equal to What is the product of any number multiplied by one? Answer: number Once you have calculated the of all the placeholders where a 1 appears, we add the answers together. What is the sum of 8+4+? Answer: The decimal equivalent of is, which is shown in the green box. 8

Converting from Decimal to Binary Can be done two different ways Long Division Convert from decimal to binary. Sort by the original number by our base, which is. Notice that we do not directly divide 35 by and get 16. You must divide the numbers so that you have a of or at the end of the process. Once you reach a 0 or 1 as the remainder you move to the next step. Using the we got in the first step (35 divided by ), we move to the second step, which is dividing by. We the process until we have in the,, and. Now here comes the tricky part. Example: 1 3 1 5 8 1 1 4 8 8 4 4 1 0 1 0 0 0 0 Binary Each of the zeros and ones in the remainders represent individual. These bits are in order so we have to do what we call, meaning we rewrite them putting the bit in the position when we write the number in binary format. is flipped to. Once we rewrite the number, we see that 35 in binary is 0100011. You can always check your answer by using the binary to decimal conversion method. Go ahead, check our math. = 9

Subtraction Convert 3710 to binary using subtraction Looking at our binary table what is the? Answer: number that is still less than To indicate that 3 will be used, we put a in the placeholder. Once we subtract 3 from 37 we have left, right? What is the number in our table that is still lower than 3? Answer: Skip down to the placeholder and put in a 1. What is the only number left that we can use that is lower than or equal to 1? Answer: Now we put a in the placeholder. Continue the subtraction process until we get zero as an answer. What do you think we do with all those blank spaces in the table? Answer: Unlike using the division method, you have to flip the bits in this case, so the binary representation of =. 10

Hexadecimal Characters You can convert directly from hex to decimal but not from decimal to hex. In order to represent the numbers (to give us our 16 characters) we use letters. A = 10, B = 11, C = 1, D = 13, E = 14, and F = 15. Each is equal to (combination of zeros and ones), and like binary, can be combined to create even larger numbers. Hexadecimal (Hex) Binary Decimal 0001 1 3 0011 0100 4 5 5 6 0110 0111 7 8 8 9 1001 1010 10 B 11 C 1100 1101 13 E 14 F 1111 As with binary and decimal, is a numbering system. Each placeholder uses as its base and is equal to 16 to an exponent. 11

Look at the table. is the hexadecimal number we are going to convert to decimal. By looking at the chart, I can see that we are going to use the following values: and because there are characters in those placeholders. Note that the color red indicates which numbers we will use to convert to a value. Using the formal method again and for easier reading, we will we use to the blue box on the right of the slide. Just like converting binary, once you have calculated the where a character appears, we the answers together. the of all the placeholders What is the sum of 40 + 15? Answer: The decimal equivalent of is,which is shown in the green box. 1

Decimal to Hex Conversion Convert 5410 to Hexadecimal The easiest way to convert a decimal number to hex is to go to at it using the subtraction method to go from decimal to binary. first. Let s look Convert from to binary Convert from binary to Now we know that is equal to in binary. Here is where we take the next step. Remember that when we first discussed hexadecimal and looked at the hex/binary/decimal table you learned that each hex character represents binary bits. Note that we have the binary bits into of. Each of the four bits are then into a character. Looking first at the left-hand group of four: hex? Answer: Look at the second group of four: Answer:. How would is that number represented in. How would you represent that number in hex? While it looks like 5410 in hex is thirty-six,it is actually read as. 13

Convert 1810 to Hexadecimal Decimal to binary Binary to hex Rewriting math in Programming Parentheses Multiplication and/or division in the order they appear Addition and/or subtraction in the Writing Formulas for Computer Programs What is the formula in the green box? Answer: Area of a circle Computer programs do not recognize the symbol for Pi and there are no options for superscripts to indicate exponents in the majority of compilers. This very common formula must be rewritten in a way a computer program can decipher it. 14

In order to represent exponents, we use what s called a carrot top, which you see in the red box and you get by pressing. To represent you must use the value. For most applications 3.14 is adequate; however, for more precise calculations, you can use as many decimal places as you require. You can use virtually any variable to represent the A; however, you must remember that certain words are and can vary from language to language, so be cautious and document your code so that other programmers will be able to understand your code easily. Looking at the blue box, we see how the same formula would be written in a computer program. Notice we have used the top to indicate the and the number 3.14 to represent. r has been left alone with the assumption that the radius is either in or by the user at some earlier point in the program. Rewrite the formula for the slope of a line Using Math in Computer Programming Math is universal. The of programs that are written involve some type of. The formulas can range from very simple to highly complex. Used to Solve and or complex calculations for a company Track data sets in calculations Create files (programs) Create systems Machine Language Everything that happens within a computer all the way from the GUI we see to the files we save is into language. Each entered into the machine; each the user issues is translated into codes. Boolean Operators Because of some of the programs you will write, we also need to discuss the or Boolean operators in computer programming. These operators have their own, fit into, and have a specific of operation. 15

Boolean/Logic (or bool) Operators a. Also called Operators or just b. Logical operators that or a. = false b. = true c. Three basic bool operators a. = arguments must be true for the statement to return True. b. = argument may be for the statement to return True. c. = the statement to if it returns and if it returns. d. Order of operations as with PEMDAS, groups are evaluated and operators are evaluated in the following order: a. b. c. d. e. f. g. 16

Truth Tables These are truth tables. tables help us to visualize all possible results of or comparisons. The results of AND and NOTAND are in the blue tables while the results of OR and NOTOR are in the green tables. Truth tables help us step through our program code and determine if our is sound. 17

Binary, Hex, and Decimal Oh My Student Notes Handout a. Natural numbers a. Zero and any number obtained by repeatedly adding one to it b. Ex. 0, 1, 3, 100 b. Integers a. Any whole number b. Includes negative numbers and zero c. Positional Numbering System a. The number depends on the position of the digits to represent the number. d. Number base a. The base (or radix) is the number of single digits used to represent numbers in a positional numerical system. Any number to the 0 power is equal to 1. Example: 0 = 1 Any number to the 1 st power is equal to that number. Example: 1 = 7 * 10 = 7 * 100 = 700 1 * 10 = 4 * 10 = + 0 0 5 * 10 = 5 * 1 = + 5 75 18

Converting from Decimal to Binary Base The base of a number is indicated by a subscript value at the end of the number. If there is no subscript the base is assumed to be 10 (or decimal). Uses 0 and 1 Binary uses two as its base so each placeholder is equal to two to an exponent. Since we are using two single characters we use zero and one as our two digits. Consider the binary number 00001110. This is where binary digits (0s and 1s) go Do you see how each placeholder doubles in value? This makes binary one of the easiest numbering systems to convert to decimal. Using basic addition, we can take any binary number and convert it to a decimal equivalent. As long as you memorize the pattern all you have to do is add the value of the placeholders where a 1 appears. 19

Convert 0001110 from binary to decimal Look at the table. In the top row you notice there are only have zeros and ones. This one is a little easier for you by adding the table and colors. This is the binary number we are going to convert to decimal, 00001110. By looking down the chart you can see that we are going to use the following values: 3,, and 1 because there are 1s in those placeholders. Note that red indicates which numbers we will use to convert to a decimal value. Using the formal method, we would transfer the digits to the blue box you see on the right of the slide. The vertical alignment makes things easier to read. I like to use the vertical alignment to make things easier to read. We start with 18; determine that there is a zero in that placeholder. What is the answer when you multiply any number by zero? Answer: zero Moving down the line we have zeros until we get to the place holder 3, which is equal to 8 right? This placeholder has a one instead of a zero. What is the product of any number multiplied by one? Answer: That number Once you have calculated the products of all the placeholders where a 1 appears, we add the answers together. What is the sum of 8+4+? Answer: 14 The decimal equivalent of 00001110 is 14, which is shown in the green box. Converting from Decimal to Binary Can be done two different ways 0

Long division Subtraction Long Division Convert 3510 from decimal to binary. Start by dividing the original number by our base, which is. Notice that we do not directly divide 5 by and get 16. You must divide the numbers individually so that you have a remainder of zero or one at the end of the process. Once you reach a 0 or 1 as the remainder you move to the next step. Using the quotient we got in the first step (35 divided by ), we move to the second step, which is dividing 17 by. We repeat the process until we have zero in the quotient, dividend, and remainder. Now here comes the tricky part. Example: 1 3 1 5 1 8 1 1 1 4 8 8 0 4 4 0 1 0 0 1 0 1 0 0 0 0 Binary Each of the zeros and ones in the remainders represent individual bits. These bits are in reverse order so we have to do what we call flipping the bits, meaning we rewrite them putting the rightmost bit in the leftmost position when we write the number in binary format. 1100010 is flipped to 0100011. Once we rewrite the number we see that 35 in binary is 0100011. You can always check your answer by using the binary to decimal conversion method. Go ahead, check our math. 0100011 = 35 1

Subtraction Convert 3710 to binary using subtraction Looking at our binary table what is the highest number that is still less than 37? Answer: 3 To indicate that 3 will be used, we put a 1 in the 5 placeholder. Once we subtract 3 from 37 we have 3 left, right? What is the highest number in our table that is still lower than 3? Answer: Skip down to the 1 placeholder and put in a 1. What is the only number left that we can use that is lower than or equal to 1? Answer: 1 Now we put a 1 in the 0 placeholder. Continue the subtraction process until we get zero as an answer. What do you think we do with all those blank spaces in the table? Answer: Fill them with zeros because they are not used. Unlike using the division method, you do not have to flip the bits in this case, so the binary representation of 37 10 = 00100011.

Hexadecimal Characters 0 9 A F You can convert directly from hex to decimal but not from decimal to hex. In order to represent the numbers 10 15 (to give us our 16 characters) we use letters. A = 10, B = 11, C = 1, D = 13, E = 14, and F = 15. Each character is equal to four bits (combination of zeros and ones), and like binary, can be combined to create even larger numbers. Hexadecimal (Hex) Binary Decimal 1 0001 1 0010 3 0011 3 4 0100 4 5 0101 5 6 0110 6 7 0111 7 8 1000 8 9 1001 9 A 1010 10 B 1011 11 C 1100 1 D 1101 13 E 1110 14 F 1111 15 As with binary and decimal, hexadecimal is a positional numbering system. Each placeholder uses 16 as its base and is equal to 16 to an exponent. 3

Look at the table. FF is the hexadecimal number we are going to convert to decimal. By looking down the chart, I can see that we are going to use the following values: 16 1 and 16 0 because there are characters in those placeholders. Note that I have used the color red to indicate which numbers we will use to convert to a decimal value. Using the formal method again and for easier reading, we will transfer the digits we use to the blue box on the right of the slide. Just like converting binary, once you have calculated the products of all the placeholders where a character appears, we add the answers together. What is the sum of 40 + 15? Answer: 55 The decimal equivalent of FF16 is 55, which is shown in the green box. 4

Decimal to Hex Conversion Convert 5410 to Hexadecimal The easiest way to convert a decimal number to hex is to go to binary first. Let s look at it using the subtraction method to go from decimal to binary. Convert from decimal to Convert from binary to hex Now we know that 5410 is equal to 00110110 in binary. Here is where we take the next step. Remember that when we first discussed hexadecimal and when we looked at the hex/binary/ decimal table you learned that each hex character represents four binary bits. Note that we have divided the binary bits into groups of four. Each of the four bits are then translated into a hex character. Looking first at the left-hand group of four: 0011. How would you represent that number in hex? Answer: 3 Look at the second group of four: 0110. How would you represent that number in hex? Answer: 6 While it looks like 5410 in hex is thirty-six, it is actually read as three six. 5

Convert 1810 to Hexadecimal Rewriting math in Programming PEMDAS Parentheses Exponents Multiplication and/or division in the order they appear Addition and/or subtraction in the order they appear Writing Formulas for Computer Programs What is the formula in the green box? Answer: Area of a circle 6

Computer programs do not recognize the symbol for Pi and there are no options for superscripts to indicate exponents in the majority of compilers. This very common formula must be rewritten in a way a computer program can decipher it. In order to represent exponents, we use what s called a carrot top, which you see in the red box and you get by pressing shift+6. To represent Pi you must use the numerical value 3.14. For most applications 3.14 is adequate; however, for more precise calculations, you can use as many decimal places as you require. You can use virtually any variable to represent the A; however, you must remember that certain words are reserved words and can vary from language to language, so be cautious and document your code so that other programmers will be able to understand your code easily. Looking at the blue box we see the way we would write the same formula in a computer program. Notice we have used the carrot top for the exponent and the number 3.14 to represent Pi. r has been left alone with the assumption that the radius is either read in or entered by the user at some earlier point in the program. Rewrite the formula for the slope of a line Using Math in Computer Programming Math is universal. The majority of programs that are written involve some type of calculation. The formulas can range from very simple to highly complex. Used to Solve repetitive and or complex calculations Payroll for a company Track complex data sets in scientific calculations Create executable files (programs) Create automated systems Machine Language Everything that happens within a computer all the way from the GUI we see to the files we save is translated into machine language. Each character entered into the machine; each instruction the user issues is translated into binary codes. 7

Boolean Operators Because of some of the programs you will write, we also need to discuss the logical or Boolean operators in computer programming. These operators have their own symbols, fit into PEMDAS, and have a specific order of operations. Boolean/Logic (or bool) Operators a. Also called Logical Operators or just bool b. Logical operators that return true or false a. 0 = false b. 1 = true c. Three basic bool operators a. and = and - AND: both arguments must be true for the statement to return True. b. - OR: either argument may be true for the statement to return True. c.! NOT: toggles the statement to False if it returns True and True if it returns False. d. Order of operations As with PEMDAS, parenthetical groups are evaluated first and operators are evaluated in the following order: a. NOT (!) b. Multiplication/division (*, /) c. Addition/subtraction (+, -) d. Relational operators (<, <=, >, >=) e. NOT Equal (!=) f. AND (andand) g. OR ( ) 8

Truth Tables These are truth tables. Truth tables help us to visualize all possible results of Boolean or logical comparisons. The results of AND and NOTAND are in the blue tables while the results of OR and NOTOR are in the green tables. Truth tables help us step through our program code and determine if our logic is sound and rational. 9

Binary to Decimal Worksheet Convert the following numbers from binary to decimal. Please show your work. Do not use electronic devices. a. 10101001 b. 00110010 c. 00111100 d. 11101100 e. 00001000 f. 00101000 g. 00011000 h. 10011001 i. 11111111 j. 01100000 30

Binary to Decimal Worksheet KEY Convert the following numbers from binary to decimal. Please show your work. Do not use electronic devices. 1. 10101001-169. 00110010-50 3. 00100100-36 4. 11101100-36 5. 00001000-8 6. 01001000-7 7. 00011000-4 8. 10011001-153 9. 11111111-55 10. 01100000-69 31

Decimal to Binary Worksheet Convert the following decimal numbers to binary. For the first five you may use the subtraction method. For the second five you must use the long division method. You must show all work. No electronic devices are allowed. Please use a separate sheet of paper. 1. 19. 168 3. 53 4. 169 5. 17 6. 5 7. 173 8. 17 9. 5 10. 39 3

Decimal to Binary Worksheet KEY Convert the following decimal numbers to binary. For the first five you may use the subtraction method. For the second five you must use the long division method. You must show all work. No electronic devices are allowed. Please use a separate sheet of paper. 1. 19 = 11000000. 168 = 10100100 3. 53 = 11111101 4. 169 = 10101001 5. 17 = 00010001 6. 5 = 00011001 7. 173 = 10101101 8. 17 = 01111111 9. 5 = 00001001 10. 39 = 00100111 33

Hexadecimal to Decimal Conversion You will need to convert the numbers below from hexadecimal to decimal format. Please do not use a calculator (or any other electronic device) and show all work. 1. 016. 3016 3. 1016 4. 0F16 5. F016 6. E116 7. 8016 8. AB16 9. C116 10. 0D16 34

Hexadecimal to Decimal Conversion KEY You will need to convert the numbers below from hexadecimal to decimal format. Please do not use a calculator (or any other electronic device) and show all work. 1. 016 =. 3016 = 48 3. 1016 = 16 4. 0F16 = 15 5. F016 = 40 6. E116 = 5 7. 8016 = 18 8. AB16 = 171 9. C116 = 193 10. 0D16 = 13 35

Binary to Hexadecimal Conversions Convert the following numbers from binary to hexadecimal. Please show your work. Do not use electronic devices. 1. 10101001. 00110010 3. 00111100 4. 11101100 5. 00001000 6. 00101000 7. 00011000 8. 10011001 9. 11111111 10. 01100000 36

Binary to Hexadecimal Conversions KEY Convert the following numbers from binary to hexadecimal. Please show your work. Do not use electronic devices. 1. 10101001 = A916. 00110010 = 316 3. 00111100 = 3C16 4. 11101100 = EC16 5. 00001000 = 0816 6. 00101000 = 916 7. 00011000 = 1816 8. 10011001 = 9916 9. 11111111 = FF16 10. 01100000 = 6016 37

Decimal to Hexadecimal Conversions Convert the numbers below from decimal to hexadecimal. Please show all your work and do not use electronic devices. 1. 55. 33 3. 6 4. 51 5. 169 6. 17 7. 89 8. 64 9. 10. 47 38

Decimal to Hexadecimal Conversions KEY Convert the numbers below from decimal to hexadecimal. Please show all your work and do not use electronic devices. 1. 55 = FF16. 33 = 116 3. 6 = 1A16 4. 51 = 3316 5. 169 = A916 6. 17 = AC16 7. 89 = 5916 8. 64 = 4016 9. = 1616 10. 47 = F16 39

Evaluations of Expressions and Formulas Evaluate the following expressions as the computer does. Show your work NEATLY and include all calculations. Round your final answer to ONE decimal place. 1. 8 * 6 + 4 * 1 / 4 + 3^. 7.3 4. + 1.^ / (-0.6) 3. 8 * (4 6 / 3) (5 6 * 4 / 3) 4. (4.3.5) / (7 +.1 / 0.7 1) - * (4.5 / ) 5. 9 * 6 / 5 * + 4 4 ^ + 9 / 4 (-6) / 6. 35 / (6 / 3 + ^3) / (6 5) Write the following formulas in the correct form to be used in a BASIC expression. Alphabetic characters represent variables. Special symbols should be written numerically. 7. V = πh (r + ra + A ) 8. V = P 1 (1 + i) n 3 i mt 9. A = P 1 + r 10. C = (x h) + (y k) m 3a 4b 40

Evaluations of Expressions and Formulas KEY Evaluate the following expressions as the computer does. Show your work NEATLY and include all calculations. Round your final answer to ONE decimal place. 1. 8 * 6 + 4 * 1 / 4 + 3^. 7.3 4. + 1.^ / (-0.6) 8 * 6 + 4 * 1 / 4 + 9 7.3 4. + 1.44 / (-0.6) 8 1 + 4 4 / 4 + 9 7.3 4. + (-.4) 8 1 + 4 6 + 9 0.7 3 3. 8 * (4 6 / 3) (5 6 * 4 / 3) 4. (4.3.5) / (7 +.1 / 0.7 1) - * (4.5 / ) 8 * (4 ) (5 4 / 3) (1.5) / (7 + 3 1) *.5 8 * (4 ) (5 8) 1.5 / 9 4.5 8 * (-3).166 4.5 16 (-3) -4.3 19 5. 9 * 6 / 5 * + 4 4 ^ + 9 / 4 (-6) / 6. 35 / (6 / 3 + ^3) / (6 5) 9 * 6 / 5 * + 4 16 + 9 / 4 (-6) / 35 / (6 / 3 + 8) / (6 5) 54 / 5 * + 4 16 + 9 / 4 (-6) / 35 / ( + 8) / (-1) 1.6 + 4 16 +.5 (-3) 35 / 10 / (-1) 16.9-3.5 Write the following formulas in the correct form to be used in a BASIC expression. Alphabetic characters represent variables. Special symbols should be written numerically. 7. V = πh (r + ra + A ) 8. V = P 1 (1 + i) n 3 i V = (3.14 * h * (r^ + r * A + A^)) / 3 V = P * (1 ((1 + i) ^ -n) / i) 9. A = P 1 + r mt 10. C = (x h) + (y k) m 3a 4b A = P * ((1 + r / m) ^ (m * t)) C = ((x h)^) / (3 * a^) + ((y k) ^) / (4 * b) 41

Convert the following from binary to decimal: 1. 11000011. 11110010 3. 10010010 Numbering Conversions Test Convert the following from decimal to binary: 4. 54 5. 18 6. 33 Convert the following from hexadecimal to decimal: 7. F 8. 1D 9. 50 Convert the following from decimal to hexadecimal: 10. 56 11. 89 1. Convert the following from binary to hexadecimal: 13. 11001100 14. 11110000 15. 00111100 Evaluate the following equations: 16. + 16 (3 3 + ) / 6 17. 6 1 ( + 1 ) Rewrite the following equations as you would in a computer program: 18. AA = ππrr 19. xx = bb± bb 4aaaa aa 0. aa + bb = cc 4

Convert the following from binary to decimal: 7. 11000011 = 19510 8. 11110010 = 410 9. 10010010 = 14610 Convert the following from decimal to binary: 10. 5410 = 11111110 11. 1810 = 10000000 1. 3310 = 00100001 Numbering Conversions Test KEY Convert the following from hexadecimal to decimal: 1. F16 = 410. 1D16 = 910 3. 5016 = 8010 Convert the following from decimal to hexadecimal: 4. 5610 = 10016 5. 8910 = 5916 6. 10 = 1616 Convert the following from binary to hexadecimal: 7. 11001100 = CC16 8. 11110000 = F016 9. 00111100 = 3C16 Evaluate the following equations: 30. + 16 ( 3 + ) / 6 = 810 31. 6 1 ( + 1 ) = -3010 Rewrite the following equations as you would in a computer program: 3. AA = ππrr A = 3.14 * r^ 33. xx = bb+aaaa x = (-b + A *C) / ( * a) aa 34. aa + bb = cc c^ = a^ + b^ 43