Introduction to Game Design
Introduction to Game Design CSC 127
Popular in Course
Popular in ComputerScienence
This 3 page Class Notes was uploaded by Gregorio Lebsack on Monday October 5, 2015. The Class Notes belongs to CSC 127 at Canisius College taught by Jeffrey McConnell in Fall. Since its upload, it has received 64 views. For similar materials see /class/218871/csc-127-canisius-college in ComputerScienence at Canisius College.
Reviews for Introduction to Game Design
Report this Material
What is Karma?
Karma is the currency of StudySoup.
Date Created: 10/05/15
Binary Numbers Jeffrey J McConnell PhD Introduction Numbers represent quantities and can be expressed in any base We are familiar with decimal numbers which are expressed in base 10 Binary numbers are the cornerstone of computing and are expressed in base 2 This document will take a quick look at decimal numbers and then look at the binary number system Decimal Numbers The digits of a decimal number are between 0 and 9 which is one smaller than the decimal base of 10 The digits of a decimal number are called from right to left the ones digit tens digit hundreds digit thousands digit and so on That is because the quantity the number represents is that digit multiplied by 1 10 100 1000 and so on For example the number 1547 is 7 1 4 10 5 100 1 1000 Each ofthese positions represents higher and higher powers often starting with a power of zero The ones digit is multiplied by 100 which is 1 The tens digit is multiplied by 101 which is 10 The hundreds digit is multiplied by 102 which is 100 The thousands digit is multiplied by 103 which is 1000 In the case of decimal numbers the quantity represented by the number is the number itself Binary Numbers The digits of a binary number are 0 and 1 which is one smaller than the binary base of 2 We don t have names for the digits of a binary number but the process for a binary number is the same as a decimal number The quantity that a binary number represents is the digits of the binary number multiplied from right to left by increasing powers of2 For example the binary number 110100101 is 1 1 0 2 1 4 0 8 0 16 13206411281256 Converting a Binary Number to a Decimal Number One way to convert a binary number to a decimal number is to determine the quantity that the number represents which is the decimal equivalent For the previous example the binary number 110100101 representsthequantity1102140 801613206411281256whichis 421 A second way works from left to right in the binary number This process will double the previous total and then add the next digit of the number At the start the previous total is always zero The chart below shows how this would work for the 1 1 1 1 1 1 1 1 1 1 These two processes will always give the same answer so one can be used to check the accuracy of the other Let s consider a second example with the binary number 1011010110 In this case our table looks like the following Doing the conversion by adding up the powers of2 gives us 0 11 2 1 4 0 8 1 16 0 32 1 64 1 128 0 256 1 512 which also gives a decimal equivalent of 726 Converting a Decimal Number to a Binary Number When a decimal number is converted to a binary number the digits of the binary number will be determined from right to left In this process we repeatedly divide the number by 2 and see what the remainder of that division is The remainder will be 0 when the number is an even number and will be 1 when the number is an odd number The remainder represents the next digit of the binary number If you read up in the last column you will nd the binary number 110100101 which is the number of our rst example Let s look as another example Reading up the last column gives the binary number 1011010110 which is the second of our example numbers Octal and Hexadecimal Numbers Because binary numbers can get very long computer scientists frequently use octal or hexadecimal numbers An octal digit represents three binary digits There are eight possible combinations of three binary digits that are represented by the numbers from 0 to 7 A hexadecimal digit represents four binary digits There are sixteen possible combinations of four binary digits that are represented by the numbers from 0 to 9 along with the letters from A to F The chart below shows the relationship between the binary and decimal values for the octal and hexadecimal digits Converting a binary number to octal or hexadecimal is done from right to left In the case of octal groups of three digits are replaced by the octal equivalent The rst example number of 110100101 would be broken down as 110100101 and represented by 645 in octal and the second example number 1011010110 would be broken down as 001011010110 and represented by 1326 in octal Notice that additional zeros are added to the front of the number in this second case to get the leftmost digit In the case of hexadecimal groups of four digits are replaced by the hexadecimal equivalent The rst example number of 110100101 would be broken down as 000110100101 and represented by 1A5 in hexadecimal and the second example number of 1011010110 would be broken down as 001011010110 represented by 2D6 in hexadecimal Converting from octal to decimal works just like binary but we instead use powers of 8 For example 645 would convert as 5 1 4 8 6 64 which totals 421 The octal number 1326 would convert as 6 1 2 8 3 64 1 512 which totals 726 Converting from hexadecimal works just like binary as well but we instead use powers of 16 For example 1A5 would convert as 5 1 10A 16 1 256 which totals 421 The hexadecimal number 2D6 would convert as 6 1 13D 16 2 256 which totals 726