Number Systems & Binary How to count
How do we represent numbers? Early systems: Actual count : ||||| = 5 Roman numbers : XI = 11 Hard to do math: MCXXIII + CLXXIV = ????
Place Value Systems What we are used to Digits that have different meaning based on place: = 1 * 10000 + 2 * 1000 + 0 * 100 + 5 * 10 + 9 * 1 = 12059 ten thousands thousands hundreds tens ones 1 2 5 9
Decimal Numbers Base 10 : Each place increases by a power of 10 1 2 5 ten thousands 104 thousands 103 hundreds 102 tens 101 ones 100 1 2 5 9
Why Base 10? Only one thing special about base 10: Other systems have been used: Mayans : Base 20 Babylonians : Base 60
Other Bases Base determines the multiplier from one column to next = 1 * 160000 + 2 * 8000 + 0 * 400 + 5 * 20 + 9 * 1 = 176109 160-thousands 204 eight-thousands 203 four-hundreds 202 twentys 201 ones 200 1 2 5 9
Other Bases Base also determines how many digits needed: Base 10 : 10 digits : 0-9 Base 2 : 2 digits : 0-1 Base 8 : 8 digits : 0-7
Base 2 Base two Only 1 and 0 Places are powers of 2 1 = 1 * 32 + 0 * 16 + 1 * 8 + 1 * 4 + 0 * 2 + 1 * 1 = 32 + 8 + 4 + 1 = 45 thirty-twos 25 sixteens 24 eights 23 fours 22 twos 21 ones 20 1
Notation Subscript used to indicate base: 1012 101 in base 2 (numeric value of 5) 10110 101 in base 10 (numeric value of 101)
More digits = bigger numbers 4 digits we can represent values 0-15 15: 8 digits can represent 0-255 16 digits can represent 0-65535 n digits can represent 0 to (2n-1) 8 4 2 1
Counting to ten in binary Values for 1-10 (decimal) in binary: 1 0001 6 0110 2 0010 7 0111 3 0011 8 1000 4 0100 9 1001 5 0101 10 1010
Binary -> Decimal with Table Make a table like this one Write in the binary number Add up all the numbers from the top that have a 1 under them: 64 + 32 + 4 + 1 = 101 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
Decimal -> Binary with Table Make a table like this one Say we are converting 83: Look for largest number that is smaller than our value 128 64 32 16 8 4 2 1
Decimal -> Binary with Table Make a table like this one Say we are converting 83: Look for largest number that is smaller than our value We have 1 of those (0 of anything bigger) Subtract that from our number 83 – 64 = still have 19 to make 128 64 32 16 8 4 2 1
Decimal -> Binary with Table Make a table like this one Say we are converting 83: Look for largest number that is smaller than our value We have 1 of those (0 of anything bigger) Subtract that from our number 83 – 64 = still have 19 to make Look for largest value smaller than that… Now have 19 – 16 = 3 left 128 64 32 16 8 4 2 1
Decimal -> Binary with Table Make a table like this one Say we are converting 83: Look for largest number that is smaller than our value We have 1 of those (0 of anything bigger) Subtract that from our number 83 – 64 = still have 19 to make Look for largest value smaller than that… Now have 19 – 16 = 3 left Continue… need a 2, have one left… 128 64 32 16 8 4 2 1
Decimal -> Binary with Table Make a table like this one Say we are converting 83: 0101 0011 means 64 + 16 + 2 + 1 = 83 128 64 32 16 8 4 2 1
Conversion With Division/ Multiplication Binary works in powers of 2 Multiplying/dividing by 2 shifts digits
Decimal -> Binary with Division Step 1: Start with a blank answer and the number your are converting Step 2: Divide your number by 2 to make a quotient and a remainder Step 3: Place your remainder on the left side of your answer Step 4: If your quotient is 0, you are done Otherwise, make the quotient your new number and go back to step 2 Convert 105 to binary: Number ÷ 2 Q R Answer 105
Decimal -> Binary with Division Step 1: Start with a blank answer and the number your are converting Step 2: Divide your number by 2 to make a quotient and a remainder Step 3: Place your remainder on the left side of your answer Step 4: If your quotient is 0, you are done Otherwise, make the quotient your new number and go back to step 2 Convert 105 to binary: Number ÷ 2 Q R Answer 105 ÷ 2 52 1
Decimal -> Binary with Division Step 1: Start with a blank answer and the number your are converting Step 2: Divide your number by 2 to make a quotient and a remainder Step 3: Place your remainder on the left side of your answer Step 4: If your quotient is 0, you are done Otherwise, make the quotient your new number and go back to step 2 Convert 105 to binary: Number ÷ 2 Q R Answer 105 ÷ 2 52 1
Decimal -> Binary with Division Step 1: Start with a blank answer and the number your are converting Step 2: Divide your number by 2 to make a quotient and a remainder Step 3: Place your remainder on the left side of your answer Step 4: If your quotient is 0, you are done Otherwise, make the quotient your new number and go back to step 2 Convert 105 to binary: Number ÷ 2 Q R Answer 105 ÷ 2 52 1 52 ÷ 2
Decimal -> Binary with Division Step 1: Start with a blank answer and the number your are converting Step 2: Divide your number by 2 to make a quotient and a remainder Step 3: Place your remainder on the left side of your answer Step 4: If your quotient is 0, you are done Otherwise, make the quotient your new number and go back to step 2 Convert 105 to binary: Number ÷ 2 Q R Answer 105 ÷ 2 52 1 52 ÷ 2 26 01
Decimal -> Binary with Division Step 1: Start with a blank answer and the number your are converting Step 2: Divide your number by 2 to make a quotient and a remainder Step 3: Place your remainder on the left side of your answer Step 4: If your quotient is 0, you are done Otherwise, make the quotient your new number and go back to step 2 Convert 105 to binary: Number ÷ 2 Q R Answer 105 ÷ 2 52 1 52 ÷ 2 26 01 26 ÷ 2 13 001
Decimal -> Binary with Division Step 1: Start with a blank answer and the number your are converting Step 2: Divide your number by 2 to make a quotient and a remainder Step 3: Place your remainder on the left side of your answer Step 4: If your quotient is 0, you are done Otherwise, make the quotient your new number and go back to step 2 Convert 105 to binary: Number ÷ 2 Q R Answer 105 ÷ 2 52 1 52 ÷ 2 26 01 26 ÷ 2 13 001 13 ÷ 2 6 1001 6 ÷ 2 3 01001 3 ÷ 2 101001 1 ÷ 2 1101001
Decimal -> Binary with Division Step 1: Start with a blank answer and the number your are converting Step 2: Divide your number by 2 to make a quotient and a remainder Step 3: Place your remainder on the left side of your answer Step 4: If your quotient is 0, you are done Otherwise, make the quotient your new number and go back to step 2 Convert 105 to binary: Number ÷ 2 Q R Answer 105 ÷ 2 52 1 52 ÷ 2 26 01 26 ÷ 2 13 001 13 ÷ 2 6 1001 6 ÷ 2 3 01001 3 ÷ 2 101001 1 ÷ 2 1101001 128 64 32 16 8 4 2 1 = 105
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 0 * 2
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 0 * 2 + 1
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 1 * 2
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 01 1 * 2 + 1
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 01 3
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 01 3 3 * 2
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 01 3 3 * 2 + 0
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 01 3 6
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 01 3 6 6 * 2
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 01 3 6 _ 6 * 2 + 1
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 01 3 6 _ 13
Binary -> Decimal with Multiplication Step 1: Start with the number your are converting and the answer of 0 Step 2: Multiply your answer by 2 Step 3: Remove the leftmost digit of number and add it to your answer Step 4: If number has no more digits, you are done Otherwise, go back to step 2 Convert 11012 to decimal: Number Answer 1101 101 1 01 3 6 _ 13 128 64 32 16 8 4 2 1 = 13