AP CSP: Binary Number System September 1, 2016
Circle-Square-Triangle to Binary Last class we created a number systems using three different shapes. The whole point of this was to try and find and create a number system very similar to what we have already learned before. Depending on how many unique patterns you have in your number system, you can only count so high before having to add another place value to have more numbers. Now we’re going to relate our own circle-square-triangle system to decimal and traditional base-3 number system. An example is shown on the next slide. Let Circle = 0, Triangle = 1, and Square = 2
Decimal(Base 10) Circle-Square-Triangle Ternary(Base-3) CCC 000 1 CCT 001 2 CCS 002 3 CTC 010 4 CTT 011 5 CTS 012 6 CSC 020 7 CST 021 8 CSS 022 9 TCC 100 10 TCT 101 11 TCS 102 12 TTC 110 13 TTT 111 14 TTS 112 15 TSC 120
Transition to the Binary Number System Now that we know base-3 and how all number systems are alike. Let’s focus on binary, the language of computers. Binary only has two unique digits, 1 and 0. Out of these two digits we can represent any number we want to as long as we have enough bits. Decimal Binary(Base-2) 1 2 10 3 11 4 100 5 101 6 110 7 111 8 1000 9 1001 1010
Converting from Binary to decimal Remember placeholders from the decimal system, well the same concept exists in the binary system. Instead of multiples of 10s, we now have multiples of 2 in binary. If you place a 1 underneath a particular placeholder it means you multiply that 1 by the placeholder’s value. Add up all the placeholders with a 1 underneath them and you get what the binary number is equivalent to. Decimal Place Holders 1000000 100000 10000 1000 100 10 1 Ex. 6,721,395 6 7 2 1 3 9 5 = ‘ Binary Place Holders 256 128 64 32 16 8 4 2 1 0 1 0 0 1 0 0 1 1 = 137 in Decimal
Converting Decimal to Binary First list out all the binary placeholders. Then choose the place holder that is closest to the decimal number you are trying to convert but not over, and place a 1 underneath that placeholder. Place a 0 for all the placeholders to the left of that original placeholder with 1. Then visit every subsequent placeholder to the right of the original P.H. Add the P.H. value to the P.H.s’ with a one underneath. If the new value is higher then the number you are converting for then place a zero under that particular P.H. and move on to the next place holder. Example below: Convert 97 to Binary Binary Place Holders 256 128 64 32 16 8 4 2 1 0 0 1 1 0 0 0 0 1 = 64 + 32 + 1 = 97 Explain why I didn’t place a 1 under the sixteens place
Wrap-Up Explain why this joke is funny: “There are 10 kinds of people in the world, those who understand binary and those who don’t.” The link below is a website where you can test your knowledge of binary to see if you have mastered this system. http://forums.cisco.com/CertCom/game/binary_game_page.htm