DOC PREVIEW
Berkeley COMPSCI 61C - Number Representation

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1ReviewPutting it all in perspective…Data input: Analog  DigitalDigital data not nec born Analog…BIG IDEA: Bits can represent anything!!How many bits to represent π ?What to do with representations of numbers?What if too big?How to Represent Negative Numbers?Shortcomings of sign and magnitude?AdministriviaGreat DeCal courses I superviseAnother try: complement the bitsShortcomings of One’s complement?Standard Negative # RepresentationTwo’s Complement Formula2’s Complement Number “line”: N = 5Bias Encoding: N = 5 (bias = -15)How best to represent -12.75?And in summary...REFERENCE: Which base do we use?Two’s Complement for N=32Two’s comp. shortcut: Sign extensionCS61C L02 Number Representation (1)Garcia, Spring 2010 © UCBLecturer SOE Dan Garciawww.cs.berkeley.edu/~ddgarciainst.eecs.berkeley.edu/~cs61c CS61C : Machine StructuresLecture #2 – Number Representation2010-01-22There is one handout today at the front and back of the room!Great book  The Universal Historyof Numbersby Georges IfrahCS61C L02 Number Representation (2)Garcia, Spring 2010 © UCBReview•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 every 2 yrs)•5 classic components of all computers Control Datapath Memory Input OutputProcessor} a b c d eWhat’ll be the most important part of a computer in the future?CS61C L02 Number Representation (3)Garcia, Spring 2010 © UCBPutting 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. CringelyCS61C L02 Number Representation (4)Garcia, Spring 2010 © UCBData input: Analog  Digital•Real world is analog!•To import analog information, we must do two things•Sample E.g., for a CD, every 44,100ths of a second, we ask a music signal how loud it is.•Quantize For every one of these samples, we figure out where, on a 16-bit (65,536 tic-mark) “yardstick”, it lies.www.joshuadysart.com/journal/archives/digital_sampling.gifCS61C L02 Number Representation (5)Garcia, Spring 2010 © UCBDigital data not nec born Analog…hof.povray.orgCS61C L02 Number Representation (6)Garcia, Spring 2010 © UCBBIG IDEA: Bits can represent anything!!•Characters?•26 letters  5 bits (25 = 32)•upper/lower case + punctuation  7 bits (in 8) (“ASCII”)•standard code to cover all the world’s languages  8,16,32 bits (“Unicode”)www.unicode.com•Logical values?•0  False, 1  True•colors ? Ex:•locations / addresses? commands?•MEMORIZE: N bits  at most 2N thingsRed (00) Green (01) Blue (11)CS61C L02 Number Representation (7)Garcia, Spring 2010 © UCBHow many bits to represent π?a) 1b) 9 (π = 3.14, so that’s 011 “.” 001 100) c) 64 (Since Macs are 64-bit machines) d) Every bit the machine has!e) ∞CS61C L02 Number Representation (8)Garcia, Spring 2010 © UCBWhat to do with representations of numbers?•Just what we do with numbers!•Add them•Subtract them•Multiply them•Divide them•Compare them•Example: 10 + 7 = 17•…so simple to add in binary that we can build circuits to do it!•subtraction just as you would in decimal•Comparison: How do you tell if X > Y ? 1 0 1 0+ 0 1 1 1-------------------------1 0 0 0 111CS61C L02 Number Representation (9)Garcia, Spring 2010 © UCBWhat if too big?•Binary bit patterns above are simply representatives of numbers. Strictly speaking they are called “numerals”.•Numbers really have an  number of digits•with almost all being same (00…0 or 11…1) except for a few of the rightmost digits •Just don’t normally show leading digits•If result of add (or -, *, / ) cannot be represented by these rightmost HW bits, overflow is said to have occurred.00000 00001000101111111110unsignedCS61C L02 Number Representation (10)Garcia, Spring 2010 © UCBHow to Represent Negative Numbers?•So far, unsigned numbers•Obvious solution: define leftmost bit to be sign! •0  + 1  – •Rest of bits can be numerical value of number•Representation called sign and magnitude00000 00001 01111...100001000111111 ...00000 00001 01111... 10000 11111...BinaryodometerBinaryodometer(C’s unsigned int, C99’s uintN_t)META: Ain’t no free lunchCS61C L02 Number Representation (11)Garcia, Spring 2010 © UCBShortcomings of sign and magnitude?•Arithmetic circuit complicated•Special steps depending whether signs are the same or not•Also, two zeros• 0x00000000 = +0ten• 0x80000000 = –0ten •What would two 0s mean for programming?•Also, incrementing “binary odometer”, sometimes increases values, and sometimes decreases!•Therefore sign and magnitude abandonedCS61C L02 Number Representation (12)Garcia, Spring 2010 © UCBAdministrivia•Upcoming lectures•Next three lectures: Introduction to C•Lab overcrowding•Remember, you can go to ANY discussion (none, or one that doesn’t match with lab, or even more than one if you want)•Overcrowded labs - consider finishing at home and getting checkoffs in lab, or bringing laptop to lab•If you’re checked off in 1st hour, you get an extra point on the labs!•Enrollment•It will work out, don’t worry•Exams are all open book, no need to memorize!•Soda locks doors @ 6:30pm & on weekends•Look at class website, newsgroup often!http://inst.eecs. berke ley.e du/~c s61c/ucb.class.cs61cIclickerskinz.comCS61C L02 Number Representation (13)Garcia, Spring 2010 © UCBGreat DeCal courses I supervise•UCBUGG (3 units, P/NP)•UC Berkeley Undergraduate Graphics Group•Tue 5-7pm or Wed 4-6pm in 200 Sutardja Dai•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 (2 units, P/NP)•Macintosh Software Developers for OS X•Mon 5-7pm in 200 Sutardja Dai•Learn to program the Macintosh or iPhone or iPod Touch!•No prereqs (other than interest)•http://msdosx.berkeley.eduCS61C L02 Number Representation (14)Garcia, Spring 2010 © UCBAnother try: complement the bits•Example: 710 = 001112 –710 = 110002•Called One’s Complement•Note: positive numbers have leading 0s, negative numbers have leadings


View Full Document

Berkeley COMPSCI 61C - Number Representation

Documents in this Course
SIMD II

SIMD II

8 pages

Midterm

Midterm

7 pages

Lecture 7

Lecture 7

31 pages

Caches

Caches

7 pages

Lecture 9

Lecture 9

24 pages

Lecture 1

Lecture 1

28 pages

Lecture 2

Lecture 2

25 pages

VM II

VM II

4 pages

Midterm

Midterm

10 pages

Load more
Download Number Representation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Number Representation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Number Representation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?