Coding Schemes and Number Systems 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 Coding Schemes and Number Systems
Quote "There are only 10 types of people in the world - those who understand binary, and those who don't." -unknown Worksheet with questions similar to those on the quiz Feel free to work together When doing quiz: Do not simply use a conversion app on the web. Do the conversions on your own first! Then if you want to check your answer, you can check it.
Coding Schemes At the lowest level, everything in a computer is represented by 1s and 0s, called bits Numbers Characters Complex data Bit – binary digit A coding scheme is used by a computer to represent characters Images Audio Networking A bit is the smallest element of computer storage The way a bit of information is actually stored depends on the storage medium We will learn more about that in Chapter 7: Storage
Coding Schemes ASCII – most widely used coding scheme EBCDIC – used on some mainframes and high-end servers Unicode – used by several operating systems and programming languages Contains ASCII as a subset ASCII = American Standard Code for Information Interchange
Coding Schemes ASCII, EBCDIC Store each character in one byte (8 bits) 256 characters represented Characters for English and western European languages represented ASCII Symbol EBCDIC 00110111 7 11110111 00111000 8 11111000 00111001 9 11111001 01000001 A 11000001 01000010 B 11000010 01000011 C 11000011 01000100 D 11000100 01000101 E 11000101 Complete ASCII table: http://www.rapidtables.com/prog/ascii_table.htm My favorite: http://www.asciitable.com/
Coding Schemes Unicode Store each character in two(+) bytes (16 bits) 65,536+ characters represented First 256 codes are same as ASCII codes Includes codes for ideograms – symbols used in Asian and other languages – allows more languages/characters than only ASCII Anyone know what languages these are from?
Coding Schemes: Conversion Exercise Try these exercises using http://www.asciitable.com/ Convert to ASCII binary codes: Tree Convert to ASCII decimal codes: Go Team! Decipher ASCII codes from binary: 01010011 01110100 01000001 01110010 Decipher ASCII codes from decimal: 67 73 83 64 80 67 67 Show ASCII Code chart on course web site: decimal and binary codes Tree = 01010100 01110010 01100101 01100101 Go Team! = 71 111 32 84 101 97 109 33 67 73 83 64 80 67 67 = CIS@PCC 01010011 01110100 01000001 01110010 = StAr
Coding Schemes: Conversion Exercise Check your answers: Convert to ASCII binary codes: Tree 01010100 01110010 01100101 01100101 Convert to ASCII decimal codes: Go Team! 71 111 32* 84 101 97 109 33 * What does 32 stand for? Decipher ASCII codes from binary: 01010011 01110100 01100001 01110010 S t a r Decipher ASCII codes from decimal: 67 73 83 64 80 67 67 C I S @ P C C Discovering Computers 2011: Living in a Digital World Chapter 2
Number Systems Decimal Base 10 Binary Base 2 Hexadecimal Base 16 Three number systems are commonly used with computers Decimal Base 10 Binary Base 2 Hexadecimal Base 16 1, 2, 3, … 10, 11, 12 1, 10, 11, … 1010, 1011, 1100 1, 2, 3, … A, B, C
1 2 3 Number Systems Decimal Number System “deci” prefix = 10 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 10 number system Show cycling through digits as one counts up: 0, 1, 2, … 9, 10 (move over one place value and start again) 123 in the decimal number system represents the quantity one hundred and twenty three The number we use are just symbols – distinction between the symbol used and the quantity represented Other examples (on board): 4018 = 4*103 + 0*102 + 1*101 + 8*100 312,000 = … Now that we understand the decimal number system, we can see that other number systems act the same way, just using a different base value. 1 2 3 102 101 100 = 1*102 + 2*101 + 3*100 = 100 + 20 + 3
Discovering Computers 2011: Living in a Digital World Chapter 2 Number Systems Each number system has a set of place values. Any number (except zero) raised to the zero power = 1 Any number raised to the 1st power is itself Any number raised to the 2nd power is that number times itself You should know the place values for the decimal system we use every day. See Binary Place_Values and Hexadecimal Place Values Number Systems See Number Conversion Discovering Computers 2011: Living in a Digital World Chapter 2
1 0 1 Number Systems Binary Number System “bi” prefix = 2 2 digits: 0, 1 Base 2 number system Everywhere we had a 10 on the previous slide, we can replace with a 2 Write table on board: 22 = 4, 23 = 8, … Do other examples on board: 1011 = 1*23 + 0*22 + 1*21 + 1*20 1010000000 = 29 + 27 = 512 + 128 = 640 1 0 1 22 21 20 101 = 1*22 + 0*21 + 1*20 = 4 + 0 + 1 = 5
1 2 3 Number Systems Hexadecimal Number System aka Hex “hexadeci” prefix = 16 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F In the Hexadecimal (Base 16) number system we use the letters A-F to represent the additional 6 digits. We have to add symbols to get 16 digits The symbols 123 in hex represent the quantity 291 Write table on board: 161 = 16, 162 = 256, 163 = 4096 Do other examples on board: AB = 10*161 + 11*160 = 160 + 11 = 171 300F = 3*163 + 0 + 0 + 15*160 = 3*4096 + 15 = 12288+ 15 = 12303 1 2 3 162 161 160 123 = 1*162 + 2*161 + 3*160 = 256 + 32 + 3 = 291
Number Systems Converting between number systems Binary or hex to decimal: Use place values Decimal to binary : Write number as a sum of powers of 2 200 to binary 200 = 128 + 72 200 – 128 = 72 200 = 128 + 64 + 8 72 – 64 = 8 200 = 27 + 26 + 23 200 = 11001000 Anything to decimal: use place values just like we have shown -> Show place value pages on our web site (Assign 2 assistance) 200 to binary: check chart: 128 is largest less than 200, … Other examples: 512 = 29 = 1000000000 513 = 1000000001
Number Systems Converting between number systems Decimal to hex: Convert decimal to binary, then to hex Binary to hex and hex to binary: 4 binary digits = 1 hex digit (see Binary to Hex Conversion) Binary – Hex Chart on web site Why does 4 binary digits = 1 hex digit? 16 is a power of 2: 16 = 24 1011 0101 0010 1111 B 5 2 F
Number Systems Why hex? Network mask More compact representation of binary numbers Network mask Host: 01010101.01010101.01010101.01010101 85 . 85 . 85 . 85 Mask: 11111111.11111111.11111111.11110000 255 . 255 . 255 . 240
Exercises Convert the following binary numbers to hexadecimal: 01001111 01100011 01110100 00100000 00110011 00110001 01111010 00111101 00100110 01000100 01100101 01101011 01101100 00110010 10110111 Worksheet with questions similar to those on the quiz Feel free to work together When doing quiz: Do not simply use a conversion app on the web. Do the conversions on your own first! Then if you want to check your answer, you can check it.
Discovering Computers 2011: Living in a Digital World Chapter 2 Check your answers. 01001111 01100011 01110100 4F 63 74 00100000 00110011 00110001 20 33 31 01111010 00111101 00100110 7A 3D 26 01000100 01100101 01101011 44 65 6B 01101100 00110010 10110111 6C 32 B7 Discovering Computers 2011: Living in a Digital World Chapter 2
Exercises Worksheet with questions similar to those on the quiz Complete the following table using ASCII code (You may use an online calculator or PC calculator for the numbers). Write binary numbers using 8 bits. Decimal Binary Hex ASCII char 81 48 @ 01100111 61 70 m 0110110 Worksheet with questions similar to those on the quiz Feel free to work together When doing quiz: Do not simply use a conversion app on the web. Do the conversions on your own first! Then if you want to check your answer, you can check it.
Exercises Check your answers: Decimal Binary Hex ASCII char 81 01010001 51 Q 72 01001000 48 H 64 01000000 40 @ 103 01100111 67 g 61 00111101 3D = 112 01110000 70 p 109 01101101 6D m 54 00110110 36 6 Worksheet with questions similar to those on the quiz Feel free to work together When doing quiz: Do not simply use a conversion app on the web. Do the conversions on your own first! Then if you want to check your answer, you can check it.
Quote "There are only 10 types of people in the world - those who understand binary, and those who don't." -unknown Worksheet with questions similar to those on the quiz Feel free to work together When doing quiz: Do not simply use a conversion app on the web. Do the conversions on your own first! Then if you want to check your answer, you can check it.
Coding Schemes and Number Systems 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 01110100 01101000 01101001 01110011 00100001 00100000 01000100 01101111 01101110 00100111 01110100 00100000 01110010 01100101 01100001 01100100 00100000 Coding Schemes and Number Systems