当前位置:高等教育资讯网  >  中国高校课件下载中心  >  大学文库  >  浏览文档

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

资源类别:文库,文档格式:PPT,文档页数:29,文件大小:446KB,团购合买
• Encodings – Unsigned and two’s complement • Conversions – Signed vs. unsigned – Long vs. short • Suggested reading
点击下载完整版文档(PPT)

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

点击下载完整版文档(PPT)VIP每日下载上限内不扣除下载券和下载次数;
按次数下载不扣除下载券;
24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
共29页,试读已结束,阅读完整版请下载
相关文档

关于我们|帮助中心|下载说明|相关软件|意见反馈|联系我们

Copyright © 2008-现在 cucdc.com 高等教育资讯网 版权所有