L02-ac-numbers2-c1

# L02-ac-numbers2-c1 - inst.eecs.berkeley.edu/~cs61c CS61C :...

This preview shows pages 1–9. Sign up to view the full content.

CS61C L2 Number Representation & Introduction to C (1) Chae, Summer 2008 © UCB Albert Chae Instructor inst.eecs.berkeley.edu/~cs61c CS61C : Machine Structures Lecture #2 – Number Rep & Intro to C 2008-06-24

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS61C L2 Number Representation & Introduction to C (2) Chae, Summer 2008 © UCB Review 5 classic components of all computers Control Datapath Memory Input Output Decimal for human calculations, binary for computers, hex to write binary more easily 8 bits = 2 hex digits = 1 byte Processor }
CS61C L2 Number Representation & Introduction to C (3) Chae, Summer 2008 © UCB Which base do we use? Decimal: great for humans, especially when doing arithmetic Hex: if human looking at long strings of binary numbers, its much easier to convert to hex and look 4 bits/symbol Terrible for arithmetic on paper Binary: what computers use; you will learn how computers do +, -, *, / To a computer, numbers always binary Regardless of how number is written: 32 ten == 32 10 == 0x20 == 100000 2 == 0b100000 Use subscripts “ten”, “hex”, “two” in book, slides when might be confusing

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS61C L2 Number Representation & Introduction to C (4) Chae, Summer 2008 © UCB kibi, mebi, gibi, tebi, pebi, exbi, zebi, yobi New IEC Standard Preﬁxes Make a mnemonic! 2 80 = 1,208,925,819,614,629,174,706,176 2 70 = 1,180,591,620,717,411,303,424 2 60 = 1,152,921,504,606,846,976 2 50 = 1,125,899,906,842,624 2 40 = 1,099,511,627,776 2 30 = 1,073,741,824 2 20 = 1,048,576 2 10 = 1,024 Factor Yi yobi Zi zebi Ei exbi Pi pebi Ti tebi Gi gibi Mi mebi Ki kibi Abbr Name en.wikipedia.org/wiki/Binary_prefix
CS61C L2 Number Representation & Introduction to C (5) Chae, Summer 2008 © UCB Answer! 2 XY means… X=0 --- X=1 kibi ~10 3 X=2 mebi ~10 6 X=3 gibi ~10 9 X=4 tebi ~10 12 X=5 pebi ~10 15 X=6 exbi ~10 18 X=7 zebi ~10 21 X=8 yobi ~10 24 2 53 bytes = ___?___bytes 2 87 bytes = ___?___bytes The way to remember #s Y=0 1 Y=1 2 Y=2 4 Y=3 8 Y=4 16 Y=5 32 Y=6 64 Y=7 128 Y=8 256 Y=9 512

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS61C L2 Number Representation & Introduction to C (6) Chae, Summer 2008 © UCB What 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 1 1 1
CS61C L2 Number Representation & Introduction to C (7) Chae, Summer 2008 © UCB BIG IDEA: Bits can represent anything!! Characters? 26 letters 5 bits (2 5 = 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 2 N things Red (00) Green (01) Blue (11)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS61C L2 Number Representation & Introduction to C (8) Chae, Summer 2008 © UCB How to Represent Negative Numbers?
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 12/06/2009 for the course CS cs61c taught by Professor Cory during the Summer '08 term at Berkeley College.

### Page1 / 45

L02-ac-numbers2-c1 - inst.eecs.berkeley.edu/~cs61c CS61C :...

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online