Thursday, October 28, 2010

Grover's Guide to learning Binary: From Base 2 to Base 10. [Archived]

Grover's Guide to learning Binary: From Base 2 to Base 10. I just recently submitted this as an extra credit assignment to my professor, and I thought I should re post it here for the sake of blog studying purposes. This is also a heads up to my CSE professor that it was submitted to him BEFORE this was posted to prevent plagiarizing. Grover’s Guide to Learning Binary: From Base 2 to Base 10 Base 10 numbers are the ones we have grown accustomed to throughout our daily lives. These numbers go from 0, 1, 2, 3, 4, 5, … , 9, 10, 11, 12, 13, 14, 15, …, and so on. This is known as the decimal format. Base 2 numbers are numbers that can only be formed with the use of 0 or 1. This is known as the binary format. If a question on an exam or homework asks to convert a number from base 10 to base 2, it is asking you to convert from our standard numeric convention (Decimal) to the 0/1 numeric convention (binary). A small guide for comparing Base 10 numbers with those of base 2. Base 2 – Base 10 00 – 0 01 – 1 10 – 2 11 – 3 100 – 4 101 – 5 110 – 6 111 – 7 1000 – 8 Some shortcuts I’ve noticed: (If you’re having trouble what order the 0’s and 1’s go in.) When counting up, go in the order you would go in if you were counting in decimal format. Example 1: 0 for 0 and then 1 for 1. Seeing as 2 is not allowed in binary format, you would go the next number that involves 0 and 1. In 2’s case, it would be 10. So 2 = 10 in binary. After that, you would go to the next number up, 3 would be 11. Since we are out of numbers in that place, we would have to stretch the number to a string of four 0’s and 1’s, hence why 4 is 1000, 5 would be 1001, and so on. Example 2: The length of the binary string increases in 2n 21 = 10 (2 = 1 zero) 22= 100 (4 = 2 zeros) 23= 1000 (8 = 3 zeros) 24= 10000 (16 = 4 zeros) So, if I wanted to find out 17, for example. I know 24 = 10000, 17 would be the number after 16, so I would add a 1, making it 10001. 18 would be 10010. (Since 10010 is logically the next number in the series that has a 0 and a 1.) Of course, if you want the answer quickly, all of this can take time and be quite inefficient. However, turning a number from binary to decimal is much easier. Grover’s Guide to Learning Binary: From Base 2 to Base 10 (Binary to Decimal Format) Changing a number from binary to decimal is much more simple than changing a number from decimal to binary. Lets say we were given the binary number 1100101000101000 and I wanted to turn it from binary into base number. Step 1: Make sure you start from the left of the number string and not the right. Step 2: Find a number to start with and grab that out, in this case, we will use the 1100101000101000 (Bolded part). Based on binary, we know that 10 is 2, so 11 must be 3. We will start with the bolded 11 (just above) and move to the right. For every 0 that we encounter in the string, we will multiply the number by 2. For every 1 in the string we will multiply by 2 and add 1 to it. Starting from 11 (3) and moving right along the number string. (For the sake of the tutorial, I’m using the bolded numbers as progress on the number string.) 1100101000101000 (3) 1100101000101000 (3 x 2 = 6) 1100101000101000 (6 x 2 = 12) 1100101000101000 (12 x 2 + 1 = 25) 1100101000101000 (25 x 2 = 50) 1100101000101000 (50 x 2 + 1 = 101) 1100101000101000 (101 x 2 = 202) 1100101000101000 (202 x 2 = 404) 1100101000101000 (404 x 2 = 808) 1100101000101000 (808 x 2 + 1 = 1617) 1100101000101000 (1617 x 2 = 3234) 1100101000101000 (3234 x 2 + 1 = 6469) 1100101000101000 (6469 x 2 = 12938) 1100101000101000 (12938 x 2 = 25876) 1100101000101000 (25876 x 2 = 51752) That is the end of the string, so the number is 51752

No comments: