CS 61C: Great Ideas in Computer Architecture Lecture 2 ...

[Pages:52]CS 61C: Great Ideas in Computer Architecture

Lecture 2: Numbers & C Language

Krste Asanovi & Randy Katz

Agenda

? Numbers wrap-up ? This is not on the exam! ? Break ? C Primer ? Administrivia, Break ? C Type declarations ? And in Conclusion, ...

CS 61c

Lecture 2: C Programming Language

2

Recap: Binary Number Conversion

Binary ? Decimal

Decimal ? Binary

1001010two = ?ten

74ten = ?two

Binary Decimal Value

Decimal Binary (odd?)

Digit

74

0

0

0 x 20 = 0

/2 = 37

1

1

1 x 21 = 2

/2 = 18

0

0

0 x 22 = 0

/2 = 9

1

1

1 x 23 = 8

/2 = 4

0

0

0 x 24 = 0

/2 = 2

0

0

0 x 25 = 0

/2 = 1

1

1

1 x 26 = 64

S = 74ten

Collect ? 1001010two

9/6/17

Fall 2017 - Lecture #1

3

Signed Integer Representation

How to represent -5? Sign & magnitude (8-bit example):

sign

7-bit magnitude (0 ... 127)

Rules for addition, a + b:

? If (a>0 and b>0): add b to a ? If (a>0 and b ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download