CS 104 Introduction to Computer Science and Graphics Problems Data Representation(1) Number Systems 09/12 ~ 09/16 /2008 Yang Song (Prepared by Yang Song and Suresh Solaimuthu)
Did you see this T-shirt before? There are 10 types of people; those who understand binary and those who don't.
What is Data? In computer science, data is any information in a form suitable for use with a computer. In an alternate usage, binary files (which are not human-readable) are sometimes called “data”, as distinguished from human-readable “text”.
Numerals and Number Systems Arabic Numerals: 1, 2, 3, …. Roman Numerals: I, II, III, …. Others? 一, 二, 三, …. Decimal System Uses ten digits 0 ~ 9 Base =? 4x x x x10 0 Binary System Uses 2 digits 0, 1 Base 2
Some Units for Computer Bit: single Binary Digit - 1, 0. Nibble (Nybble): 4-bit aggregation Byte (Octet): 8-bit aggregation Bigger ones? - KiloByte (KB): 2 10 (1,024) bytes - MegaByte (MB): 2 20 (1,048,576) bytes - GigaByte (GB): 2 30 (1,073,741,824) bytes
Decimal and Binary Computer “reads” binary Simple Only two symbols How can we convert them?
Binary Decimal The value of each position For Base 10, it is 10 0, 10 1, 10 2, 10 3 … etc. For Base 2, so, 2 0, 2 1, 2 2, 2 3 … etc. Convert binary into decimal: So it is: = 11 Position Value8421 Binary1011 Actual8x14x02x11x1
Decimal Binary Division: Decimal number is the dividend, divisor is the “base”, so it’s 2 now, quotient becomes new dividend and save the remainder…until quotient < base, trace back from the last quotient to ALL the remainders. Decimal 11: so, it’s Dividend1152 Quotient521 Remainder110
Another example Convert 40 (decimal) into binary number: So it is: Can you convert decimal into base-7 number? Dividend Quotient Remainder00010
Octal Number Octal has 8 symbols: 0, 1, 2, 3….7 Base 8 Convert into decimal: 1x x x x8 0 = Convert back? Convert into octal: Group them into 3 bits (why?) Can you confirm this? Dividend Quotient Remainder074
Hexadecimal Number Hexadecimal uses sixteen symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F Base 16 Range of a Byte: 00 ~ FF, why? Convert A2C into decimal 10x x x16 0 = Convert into Hexadecimal number? Convert into hexadecimal Group into 4 bits (why?) 51F 16 Confirm this one? Dividend Quotient162A(10) RemainderC(12)2