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

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

View Full Document Right Arrow Icon
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
Image of page 1

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

View Full Document Right Arrow Icon
CS61C L2 Number Representation & Introduction to C (2) Chae, Summer 2008 © UCB Revie w 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 }
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
CS61C L2 Number Representation & Introduction to C (4) Chae, Summer 2008 © UCB kibi, mebi, gibi, tebi, pebi, exbi, zebi, yobi New IEC Standard Prefixes Make a mnemonic! Name Abbr Factor kibi Ki 2 10 = 1,024 mebi Mi 2 20 = 1,048,576 gibi Gi 2 30 = 1,073,741,824 tebi Ti 2 40 = 1,099,511,627,776 pebi Pi 2 50 = 1,125,899,906,842,624 exbi Ei 2 60 = 1,152,921,504,606,846,976 zebi Zi 2 70 = 1,180,591,620,717,411,303,424 yobi Yi 2 80 = 1,208,925,819,614,629,174,706,176 en.wikipedia.org/wiki/Binary_prefix
Image of page 4
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
Image of page 5

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

View Full Document Right Arrow Icon
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
Image of page 6
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)
Image of page 7

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern