复旦大学:《计算机原理 Computer System》课程PPT课件_Integer Representations

Integer Representations
1 Integer Representations

Outline Encodings Unsigned and two' s complement Conversions Signed vs unsigned Long vs. short Suggested reading Chap 2.2
2 Outline • Encodings – Unsigned and two’s complement • Conversions – Signed vs. unsigned – Long vs. short • Suggested reading – Chap 2.2

Integral Data Types P51 Figure 2.8 C supports a variety of integral data types Represent a finite range of integers c declaration guaranteed Typical 32-bit minimum maxImum minimum maximum char 127 127 128 127 unsigned char 255 0 255 short [int] -32,767327673276832767 unsigned short 0 65535 0 65535 int -32767327672474836482147483647 unsigned [int] 0 65535 04294967295 long [int] 21474836472147483.647-2147483.6482147483647 unsigned long 0 04294967,295
3 Integral Data Types P51 Figure 2.8 • C supports a variety of integral data types – Represent a finite range of integers C declaration guaranteed Typical 32-bit minimum maximum minimum maximum char unsigned char -127 0 127 255 -128 0 127 255 short [int] unsigned short -32,767 0 32,767 65,535 -32,768 0 32,767 65,535 int unsigned [int] -32,767 0 32,767 65,535 -2,147,483,648 0 2,147,483,647 4,294,967,295 long [int] unsigned long -2,147,483,647 0 2,147,483,647 0 -2,147,483,648 0 2,147,483,647 4,294,967,295

Twos Complement Binary Bit vector [xw-1.xw-2,Xw-3,.xo Using 2's complement to represent integer Unsigned Two's Complement B2(X)=∑x,2B7(X)=-x22∑x2 0 Sign P52Eq.(2.1) P52 Eq (2.2)Bit
4 Two’s Complement • Binary – Bit vector [xw-1 ,xw-2 ,xw-3 ,x0 ] • Using 2’s complement to represent integer B2T(X) = −x w−1 2 w−1 + xi 2 i i=0 w−2 B2U(X) = xi 2 i i=0 w−1 Unsigned Two’s Complement Sign P52 Eq. (2.1) P52 Eq. (2.2) Bit

From Two's Complement to Binary If nonnegative Nothing changes 工 f negative 2 ∑21+1 i=0 2 2 2 ∑x12=∑(1-x1)2+1 i=0
5 From Two’s Complement to Binary • If nonnegative – Nothing changes • If negative − = − = + 2 0 1 2 2 1 w i w i − = − = − − = − + 2 0 2 0 1 2 2 (1 )2 1 w i i i w i i i w x x

Twos Complement Two's Complement 5 o101(raw binary) 1010 (after complement) 1011(2s complement)
6 Two’s Complement • Two’s Complement -5 0101 (raw binary) 1010 (after complement) 1011 (2’s complement)

Twos Complement Encoding Examples Binary /Hexadecimal Representation for 12345 Binary:0011000000111001 Hex: 3039 Binary/Hexadecimal Representation for -12345 Binary:1100111100111 Hex C F C 7
7 Two’s Complement Encoding Examples Binary/Hexadecimal Representation for 12345 Binary: 0011 0000 0011 1001 Hex: 3 0 3 9 Binary/Hexadecimal Representation for –12345 Binary: 1100 1111 1100 0111 Hex: C F C 7

P55 Fiqure 2.10 Weight l2.345 1234553,191 Bit value Bit Value bit Value 1248 1008 1240 1110 1110001111110011 2400 16 16 321 32 64 64 64 128 000000 l28 o1111110 128 2560 256 256 5120 512 512 1.O24 1,O24 1,024 2,0480 2,048 2.048 4.096 4096 8,1921 8192 16.384 16,384116.384 ±32,7680 32,768132,768 Total 12.345 12.345 53.191
8 P55 Figure 2.10

Numeric Range ∪nsgl ned values Umin=o Umax=2W-1 Two's Complement values Tmin =-2W-1 Tmax=2W-1-1
9 Numeric Range • Unsigned Values – Umin=0 – Umax=2w-1 • Two’s Complement Values – Tmin = -2 w-1 – Tmax = 2w-1 -1

Interesting Numbers P53 Figure 2.9 Q )uantity Word Size w 16 32 64 UMEm OxFF OXFFFF OXFFFFFFFF OxFFFFFFFFFFFFFFFF 255655354.294967,295184144.073,709,55615 TMom 0x7F 0x7FFF 0x7FFFFFFF0x7FFFFFFFFFFFFFFF 12732,7672,147483,6479,23,372036,854,75.807 TM0x800x80000x80000000x800000000000 128-32,768-2,147,483.648-9,223,372,036,854,775,808 OxFF OXFFFF OXFFFFFFFF OXFFFFFFFFFFFFFFFF 0x000x00000x000000000x000000000000000
10 Interesting Numbers P53 Figure 2.9
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Introduction to Computer Systems; Information is Bits+Context; Information Storage.ppt
- 复旦大学:《计算机原理 Computer System》课程资源_2006年期中考试题目.doc
- 复旦大学:《计算机原理 Computer System》课程资源_2006年期中考试答案.doc
- 复旦大学:《计算机原理 Computer System》课程资源_教学大纲.pdf
- 复旦大学:《计算机图形学》课后习题答案_7.docx
- 复旦大学:《计算机图形学》课后习题答案_6.docx
- 复旦大学:《计算机图形学》课后习题答案_5.docx
- 复旦大学:《计算机图形学》课后习题答案_4.docx
- 复旦大学:《计算机图形学》课后习题答案_3.docx
- 复旦大学:《计算机图形学》课后习题答案_2.docx
- 复旦大学:《计算机图形学》课后习题答案_1.docx
- 复旦大学:《电子商务》课程PPT课件_第十次课 社会化电子商务——Hold住社会化媒体营销.ppt
- 复旦大学:《电子商务》课程PPT课件_第六次课 电子商务运营与管理 Operating Your E-Business.ppt
- 复旦大学:《电子商务》课程PPT课件_第六次课 电子商务运营与管理 Getting Your E-Business Off The Ground.ppt
- 复旦大学:《电子商务》课程PPT课件_第八次课 电子商务模式与应用课程主题案例分析与展示——电子商务团购.ppt
- 复旦大学:《电子商务》课程PPT课件_第五次课 商业模式的概念与内涵(发现商业模式).ppt
- 复旦大学:《电子商务》课程PPT课件_第九次课 B2B电子商务(B2B行业平台).ppt
- 复旦大学:《电子商务》课程PPT课件_第七次课 B2C电子商务——网上零售.pptx
- 复旦大学:《电子商务》课程PPT课件_第四次课 电子商务商业计划书写作 Creating a Winning E-Business Second Edition.ppt
- 复旦大学:《电子商务》课程PPT课件_第三次课 电子商务过程及相关因素(电子商务创业).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Integer Operations; Floating Points.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Machine-Level Representation of Programs I.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Machine-Level Representation of Programs Ⅱ.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Procedure Call and Array.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Heterogeneous Data Structures & Alignment; Putting it Together; Floating Point.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Processor Architecture.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_09、10 Sequential CPU Implementation.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Pipelined Implementation Part I.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Pipelined Implementation Part II.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_12b Code Optimization(• Machine-Independent Optimization – Code motion – Memory optimization • Suggested reading).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_13 Code Optimization(• Optimizing Blockers • Understanding Modern Processor • More Code Optimization techniques • Performance Tuning).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Hardware Organization.ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Memory Hierarchy(• Random-Access Memory(RAM)• Nonvolatile Memory • Disk Storage • Locality • Memory hierarchy).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Cache Memory(• General concepts • 3 ways to organize cache memory • Issues with writes • Write cache friendly codes • Cache mountain).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Cache Memory(• Cache mountain • Matrix multiplication).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Virtual Memory(• Virtual Space• Address translation • Accelerating translation• Different points of view).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Virtual Memory(• Multilevel page tables • Different points of view • Pentium/Linux Memory System • Memory Mapping).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Dynamic Memory Allocation(• Implementation of a simple allocator • Explicit Free List • Segregated Free List).ppt
- 复旦大学:《计算机原理 Computer System》课程PPT课件_Linking II(• Static linking • Symbols & Symbol Table • Relocation • Executable Object Files • Loading).ppt
- 复旦大学:《计算机原理 Computer System》习题PPT课件_chapter2.pptx