inst eecs. berkeley. edu/vcs61c CS61C. Machine Structures Lecture #2-Number Representation 200701-19 There is one handout today at the front and back of the room! Lecturer SoE Dan Garcia www.cs.bErkeley.edu/addgarcia Great book→ The Universal History of Numbers 该图片 by Georges Ifrah CS61C L02 Number Re presentation( Garcia, Spring 2007
CS61C L02 Number Representation (1) Garcia, Spring 2007 © UCB Lecturer SOE Dan Garcia www.cs.berkeley.edu/~ddgarcia inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #2 – Number Representation 2007-01-19 There is one handout today at the front and back of the room! Great book The Universal History of Numbers by Georges Ifrah
Great DeCal courses I supervise(2 units) UCBUGG UC Berkeley Undergraduate Graphics Group Thursdays 5: 30-7: 30pm in 310 Soda Learn to create a short 3D animation No prereqs(but they might have too many students, so admission not guaranteed http://ucbugg.berkeleyedu MS-DOS X Macintosh Software Developers for os x Thursdays 5-7pm in 320 Soda Learn to program the Macintosh and write an awesome GUI application No preregs(other than interest) httpl/msdosx.berkeley.edu Garcia, Spring 2007
CS61C L02 Number Representation (2) Garcia, Spring 2007 © UCB Great DeCal courses I supervise (2 units) • UCBUGG • UC Berkeley Undergraduate Graphics Group • Thursdays 5:30-7:30pm in 310 Soda • Learn to create a short 3D animation • No prereqs (but they might have too many students, so admission not guaranteed) •http://ucbugg.berkeley.edu • MS-DOS X • Macintosh Software Developers for OS X • Thursdays 5-7pm in 320 Soda • Learn to program the Macintosh and write an awesome GUI application • No prereqs (other than interest) •http://msdosx.berkeley.edu
Review Continued rapid improvement in computing 2X every 2.0 years in memory size; every 1.5 years in processor speed every 1.0 year in disk capacity; Moores Law enables processor (2x transistors/chip -1.5 yrs) 5 classic components of all computers Control Datapath Memory Input Output Pr rocessor Number Re presentation Garcia, Spring 2007
CS61C L02 Number Representation (3) Garcia, Spring 2007 © UCB Review •Continued rapid improvement in computing • 2X every 2.0 years in memory size; every 1.5 years in processor speed; every 1.0 year in disk capacity; • Moore’s Law enables processor (2X transistors/chip ~1.5 yrs) •5 classic components of all computers Control Datapath Memory Input Output Processor }
My goal as an instructor To make your experience in CS61C as enjoyable informative as possible Humor, enthusiasm, graphics technology-in-the-news in lecture Fun, challenging projects HW Pro-student policies(exam clobbering) To maintain cal EECS standards of excellence Your projects exams will be just as rigorous as every year. Overall B-avg · To be an hKn“7.0”man I know I speak fast when I get excited about material lm told every semester Help me slow down when I go toooo fast Please give me feed back so I improve Why am I not 7.0 for you? I will listen!! CS61C L02 Number Re presentation(4) Garcia, Spring 2007
CS61C L02 Number Representation (4) Garcia, Spring 2007 © UCB My goal as an instructor • To make your experience in CS61C as enjoyable & informative as possible • Humor, enthusiasm, graphics & technology-in-the-news in lecture • Fun, challenging projects & HW • Pro-student policies (exam clobbering) • To maintain Cal & EECS standards of excellence • Your projects & exams will be just as rigorous as every year. Overall : B- avg • To be an HKN “7.0” man • I know I speak fast when I get excited about material. I’m told every semester. Help me slow down when I go toooo fast. • Please give me feedback so I improve! Why am I not 7.0 for you? I will listen!!
Putting it all in perspective development cycle as the computer ne If the automobile had followed the sar Robert X Cringely Number Re presentation(5 Garcia, Spring 2007
CS61C L02 Number Representation (5) Garcia, Spring 2007 © UCB Putting it all in perspective… “If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside.” – Robert X. Cringely
Decimal numbers: Base 10 Digits:0,1,2,3,4,5,6,7,8,9 Example: 3271 (3x10)+(2x102)+(7X101)+1X109 Number Re presentation Garcia, Spring 2007
CS61C L02 Number Representation (6) Garcia, Spring 2007 © UCB Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x103 ) + (2x102 ) + (7x101 ) + (1x100 )
Numbers: positional notation Number Base B= B symbols per digit Base10( Decimal):0,1,2,3,4,5,6,7,8,9 Base 2 (Binary): 0, 1 Number representation 31030 d,do is a 32 digit number vaue=37XB31+030×B30+…+01 B1+d×B0 Binary: 0, 1 (n binary digits called"bits 0b11010=1×24+1×23+0×22+1×21+0×20 =16+8+2 #s often written =26 0b... Here 5 digit binary turns into a 2 digit decimal Can we find a base that converts to binary easily? CS61C L02 Number Re presentation Garcia, Spring 2007
CS61C L02 Number Representation (7) Garcia, Spring 2007 © UCB Numbers: positional notation • Number Base B B symbols per digit: • Base 10 (Decimal): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Base 2 (Binary): 0, 1 • Number representation: • d31d30 ... d1d0 is a 32 digit number • value = d31 B31 + d30 B30 + ... + d1 B1 + d0 B0 • Binary: 0,1 (In binary digits called “bits”) • 0b11010 = 12 4 + 12 3 + 02 2 + 12 1 + 02 0 = 16 + 8 + 2 = 26 • Here 5 digit binary # turns into a 2 digit decimal # • Can we find a base that converts to binary easily? #s often written 0b…
Hexadecimal Numbers: Base 16 Hexadecimal 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F Normal digits 6 more from the alphabet In C, written as OX.(e.g., OXFAB5) Conversion: BinarysHex 1 hex digit represents 16 decimal values 4 binary digits represent 16 decimal values =1 hex digit replaces 4 binary digits One hex digit is a“ nibble". Two is a“byte” Example: 101011000011( binary)=0x CS61C L02 Number Re presentation(8 Garcia, Spring 2007
CS61C L02 Number Representation (8) Garcia, Spring 2007 © UCB Hexadecimal Numbers: Base 16 • Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F • Normal digits + 6 more from the alphabet • In C, written as 0x… (e.g., 0xFAB5) • Conversion: BinaryHex • 1 hex digit represents 16 decimal values • 4 binary digits represent 16 decimal values 1 hex digit replaces 4 binary digits • One hex digit is a “nibble”. Two is a “byte” • Example: • 1010 1100 0011 (binary) = 0x_____ ?
Decimal vS Hexadecimal vs Binary Examples 0000000 0110001 101011000011 binary)0220010 OxAC3 033 0011 0440100 10111 (binary) 0550101 =00010111(6 bInary) 0660110 =0x17 0770111 0881000 0991001 0x3F9 1021010 =1111111001( binary)11B1011 2c1100 How do we convert between 13 D 1101 hex and Decimal? 14E1110 15F1111 MEMORIZE! CS61C L02 Number Re presentation(9) Garcia, Spring 2007
CS61C L02 Number Representation (9) Garcia, Spring 2007 © UCB Decimal vs. Hexadecimal vs. Binary Examples: 1010 1100 0011 (binary) = 0xAC3 10111 (binary) = 0001 0111 (binary) = 0x17 0x3F9 = 11 1111 1001 (binary) How do we convert between hex and Decimal? 00 0 0000 01 1 0001 02 2 0010 03 3 0011 04 4 0100 05 5 0101 06 6 0110 07 7 0111 08 8 1000 09 9 1001 10 A 1010 11 B 1011 12 C 1100 13 D 1101 14 E 1110 15 F 1111 MEMORIZE! Examples: 1010 1100 0011 (binary) = 0xAC3 10111 (binary) = 0001 0111 (binary) = 0x17 0x3F9 = 11 1111 1001 (binary) How do we convert between hex and Decimal?
Kilo, Mega, Giga, Tera, Peta, Exa, Zetta, Yotta physics. nist. gov/cuu/Units/binary.html Common use prefixes(all Sl, except K[k in SI] Name Abbr Factor sI size Kilo K|210=1,024 103=1,000 Mega M|20=1,048576 106=1,000,000 Giga G 230=1.073.741824 109=1,000,000,000 Tera T|240=1,099511627,776 1012=1,000,000,000,000 Peta P250=1,125,899,906,842,624 1015=1000000000,000.000 Exa E|20=1,152,921,504,606,846,976 1018=1,000,000,000,000,000,000 Zetta z20=118,591,0,717413424 1021=1000,00000000000000,000 YottaY|280=1,208,9258:19,614629,174,706,1761024=1,00000 Confusing! Common usage of“ kilobyte” means 1024 bytes, but the "correct"si value is 1000 bytes Hard Disk manufacturers Telecommunications are the only computing groups that use SI factors, so what is advertised as a 30 gb drive will actually only hold about 28 x 230 bytes, and a 1 Mbit/s connection transfers 106 bps CS61C L02 Number Re presentation(10) Garcia, Spring 2007
CS61C L02 Number Representation (10) Garcia, Spring 2007 © UCB Kilo, Mega, Giga, Tera, Peta, Exa, Zetta, Yotta • Common use prefixes (all SI, except K [= k in SI]) • Confusing! Common usage of “kilobyte” means 1024 bytes, but the “correct” SI value is 1000 bytes • Hard Disk manufacturers & Telecommunications are the only computing groups that use SI factors, so what is advertised as a 30 GB drive will actually only hold about 28 x 2 30 bytes, and a 1 Mbit/s connection transfers 106 bps. Name Abbr Factor SI size Kilo K 2 10 = 1,024 103 = 1,000 Mega M 2 20 = 1,048,576 106 = 1,000,000 Giga G 2 30 = 1,073,741,824 109 = 1,000,000,000 Tera T 2 40 = 1,099,511,627,776 1012 = 1,000,000,000,000 Peta P 2 50 = 1,125,899,906,842,624 1015 = 1,000,000,000,000,000 Exa E 2 60 = 1,152,921,504,606,846,976 1018 = 1,000,000,000,000,000,000 Zetta Z 2 70 = 1,180,591,620,717,411,303,424 1021 = 1,000,000,000,000,000,000,000 Yotta Y 2 80 = 1,208,925,819,614,629,174,706,176 1024 = 1,000,000,000,000,000,000,000,000 physics.nist.gov/cuu/Units/binary.html