SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
第2章 數位資料表示法

       資料型態
       二進位表示法
       各種進位表示法的轉換
       整數表示法
       浮點數表示法
       ASCII及Unicode




      0與1的組合




2-2




                       1
電腦表示資料的方法
      電腦以二進位方式處理資料的理由
       電腦應用到電 (正電壓和 0 電壓,電的運作方式 )、磁 ( 陽極
       和陰極,磁碟機的運作方式 ) 和光 ( 有反射光和無反射光,
       光碟機的運作方式 ) 等性質來判斷訊號,所以對於電腦而言
       二進位數字是其最能反應其物理性質的數字系統。
       電腦內部是由積體電路 ( IC ) 的電子零件所組成。如圖所
       示,IC 的電流狀態代表數字「01000001」。



                                              IC
                    8 支針腳
                              0V +5V 0V 0V 0V 0V           0V +5V


                   8 位數的二進位   0   1   0   0        0   0   0   1


2-3




      數位資訊的單位
       位元(binary digit,簡稱bit)是數位資訊的基
       本粒子,也是電腦儲存或傳遞資料的最小單
       位,常用0或1來表示
         當初電腦會採用位元表示資料,主要是因為電
         子元件的穩定狀態有兩種:一種是“開”(通常用
         來表示“1”)及一種是“關” (通常用來表示“0”)
       電腦常以8個位元為存取單位,因此8個位元稱
       為位元組(byte),一個Byte能表達28 = 256
       個訊息或符號



2-4




                                                                    2
數位資訊的單位
      縮寫                               大約位元
            全名       精確位元組個數                        範例
      單位                                組數

                                                 這個檔案的大
            Kilo
                   210 = 1,024         一千(103)
      KB
                                                 小約238 KB。
            Byte

                                        一百萬      此大姆碟的容
           Mega 20
      MB        2 = 1,048,576
                                        (106)    量為512 MB。
           Byte

                                                 本片DVD的容
            Giga
                   230 = 1,073,741,824 十億(109)
      GB
                                                 量為4.7 GB。
            Byte

                                                這部高容量磁
                   240 =
            Tera
                                       一兆(1012) 碟可儲存20 TB
      TB
            Byte   1,099,511,627,776
                                                的資料。

2-5




      資料型態

                                                數   字
                                                文   字
           資料類型                            影像、圖片

                                           語音、音樂

                                           影片、動畫



2-6




                                                             3
Coded and Decoded




2-7




      二進位表示法
       一個數字在不同的位置上所表示的數值也就不
       同,如三位數“523”,右邊的“3”在個位上表示3
       個一,中間的“2”在十位上就表示2個十,左邊的
       “5”在百位上則表示5個百,換句話說,523 = 5 x
       102 + 2 x 101 + 3
       以B為基數,則dndn-1…d2d1.r1r2…rm-1rm所表示
       的數為
       dn x Bn-1 + dn-1 x Bn-2 + … + d2 x B1 + d1 x B0 +
       r1 x B-1 + r2 x B-2 + … + rm-1 x B-(m-1) + rm x B-m
       二進位表示法:B=2

2-8




                                                             4
二進位、十進位、十六進位




2-9




       各種進位表示法的轉換
       二進位轉十進位
       10110101.11012所對應的十進位數為181.8125




2-10




                                         5
十進位整數轉二進位
       十進位181所對應的二進位數為101101012




2-11




       十進位小數轉二進位
       十進位0.8125所對應的二進位數為0.11012




2-12




                                   6
十進位0.1的二進位表示法為何?
        十進位0.1所對應的二進位數為無窮位數的
        0.000110011…2




2-13




       十六進位
        A 4-bit pattern can be represented
             by a hexadecimal digit,
                  and vice versa.
        Bit Pattern               Bit Pattern
                      Hex Digit                 Hex Digit
        ------------ ------------ ------------ ------------
           0000                      1000
                          0                         8
           0001                      1001
                          1                         9
           0010                      1010
                          2                         A
           0011                      1011
                          3                         B
           0100                      1100
                          4                         C
           0101                      1101
                          5                         D
           0110                      1110
                          6                         E
           0111                      1111
                          7                         F
2-14




                                                              7
Binary to hexadecimal and
       Hexadecimal to binary transformation




2-15




       二進位轉十六進位
       二進位數換成十六進位數時,每四個位數合成一項




       110110101.110112的十六進位表示法為1B5.D816




2-16




                                              8
十六進位轉二進位




2-17




       基底轉換法__十進位數轉換為N進位數




         十進位小數轉換成十六進位小數

   十進位整數轉換成十六進位數


2-18




                            9
八進位

             A 3-bit pattern can be
                  represented
        by an octal digit, and vice versa.

        Bit Pattern               Bit Pattern
                      Oct Digit                  Oct Digit
        ------------ ------------ ------------ ------------
            000                       100
                          0                         4
            001                       101
                          1                         5
            010                       110
                          2                         6
            011                       111
                          3                         7

2-19




                Binary to octal and
        Octal to binary transformation




2-20




                                                              10
Taxonomy of integers




       8 = 00001000        -8        11110111   11111000



2-21




       整數表示法




        Unsigned integer range: 0 … (2N-1)
2-22




                                                           11
Sign-and-magnitude integers

        In sign-and-magnitude representation,
         the leftmost bit defines the sign of the
            number. If it is 0, the number is
       positive.If it is 1, the number is negative.




2-23




       帶正負符號大小表示法




        Range: -(2N-1-1) … +(2N-1-1)
2-24




                                                      12
Sign-and-magnitude integers
                 Note:

       There are two 0s in sign-and-magnitude
        representation: positive and negative.
                   In an 8-bit allocation:
                      +0      00000000
                      -0      10000000


2-25




       一補數表示法
       給定一個十進位數值,轉換成它的一補數表示法
       步驟如下:
  步驟1 先忽略其符號,將數字的部分轉成二進位數值。

  步驟2 若該二進位數值超過n - 1 個位元, 則為「溢位」
         (overflow),無法進行轉換;否則在它的左邊補
         0,直到共有n個位元為止。
  步驟3 若所要轉換的數為正數或零,則上步所得數值即
         為所求;若為負數,則將每個位元做補數轉換,
         原為0的轉成1;原為1的轉成0。
       Range: -(2N-1-1) … +(2N-1-1)
2-26




                                                 13
-41的一補數表示法為11010110




2-27




       一補數轉十進位
        如果最左邊的位元是0,則表示該數是正數,只要將
        後面的位元以前面介紹的二進位轉十進位方式求出其
        數值即可。
        如果最左邊的位元是1,則表示該數是負數,先將每
        個位元做補數轉換,原為0的轉成1;原為1的轉成0。
        然後將該二進位轉成十進位,再加上一個負號即可。
   範例
       給定一補數11010110,因為最左邊的位元是1,所以
       我們先將這補數原為0的轉成1;原為1的轉成0,得
       00101001 。 再 將 二 進 位 的 00101001 轉 成 十 進 位 的
       41,然後加上一個負號得-41。
2-28




                                                     14
One’s complement integers
                  Note:

        There are two 0s in one’s complement
        representation: positive and negative.
                   In an 8-bit allocation:
                      +0      00000000
                      -0      11111111


2-29




             One’s complement integers
                  Note:

       In one’s complement representation,
       the leftmost bit defines the sign of the number.
       If it is 0, the number is positive.
       If it is 1, the number is negative.



2-30




                                                          15
One’s complement integers
                Note:

       One’s complement means reversing all bits.
       If you one’s complement a positive number,
       you get the corresponding negative number.
       If you one’s complement a negative number,
       you get the corresponding positive number.
       If you one’s complement a number twice, you
       get the original number.
2-31




       二補數表示法
    給定一個十進位數值,轉換成它的二補數表示法
    步驟如下:
 步驟1 先忽略其符號,將數字的部分轉成二進位數值。
 步驟2 若該二進位數值超過 n-1 個位元, 則為「溢位」
     (overflow),無法進行轉換;否則在它的左邊補
     0,直到共有n個位元為止;若所轉換的數為 -2n-
     1,則轉出來的數為1後面有n-1個0,此即為該數的

     二補數表示法,不應視為溢位。
 步驟3 若所要轉換的數為正數或零,則上步所得數值即為所
         求;若為負數,則最右邊的那些0及最右邊的第一個1
         保持不變,將其餘的每個位元做補數轉換,原為0的
         轉成1;原為1的轉成0。
         Range: -(2N-1) … +(2N-1-1)
2-32




                                                     16
40和-40的二補數表示法為何 ?
   範例
       40的二補數表示法為何? 第一步先將40轉成二進位
       數值101000;第二步在二進位數值左邊補上0,使得
       00101000共有8個位元,因為要表示的數為正數,所
       以00101000即為所求。
   範例
       -40的二補數表示法為何? 第一步先將40轉成二進位
       數值101000;第二步在二進位數值左邊補上0,使得
       00101000共有8個位元;這時所要表示的數為負數,
       所以最右邊的三個0及第一個1維持不變,其餘的將
       原為0的轉成1;原為1的轉成0,得11011000。
2-33




             Two’s complement integers
              0000000000101000
              1111111111011000

                                 216-0000000000101000
           0000000000101000
       One’s complement
           1111111111010111
                                  10000000000000000
                  +1
           1111111111011000
           1111111111011000
                                 -) 0000000000101000
                                   1111111111011000

2-34




                                                        17
Two’s complement integers
                  Note:

       In two’s complement representation,
       the leftmost bit defines the sign of the number.
       If it is 0, the number is positive.
       If it is 1, the number is negative.




2-35




       -40的二補數表示法正好是28-40




2-36




                                                          18
二補數轉十進位
        如果最左邊的位元是0,則表示該數是正數,只要將後面的
        位元以前面介紹的二進位轉十進位方式求出其數值即可。
        如果最左邊的位元是1,則表示該數是負數,保留最右邊的
        那些0及最右邊的第一個1,將其餘的每個位元做補數轉
        換,原為0的轉成1;原為1的轉成0。然後將該二進位轉成
        十進位,再加上一個負號即可。
   範例
       給定二補數11011000,因為最左邊的位元是1,所以
       我們先保留最右邊的那三個0及最右邊的第一個1,
       再將其他的位元原為0的轉成1;原為1的轉成0,得
       00101000。再將二進位的00101000轉成十進位的
       40,然後加上一個負號得-40。
2-37




       二補數表式法位元字串與數值的對應關係




2-38




                                       19
Two’s complement integers
                 Note:

       There is only one 0 in two’s complement:
                   In an 8-bit allocation:
                       0      00000000




2-39




              Two’s complement integers
                   Note:

       Two’s complement can be achieved by reversing all
       bits except the rightmost bits up to the first 1
       (inclusive).
       If you two’s complement a positive number, you get
       the corresponding negative number.
       If you two’s complement a negative number, you get
       the corresponding positive number.
       If you two’s complement a number twice, you get the
       original number.
2-40




                                                             20
Addition in two’s complement
                Note:

         Rule of Adding Integers in
            Two’s Complement
        Add 2 bits and propagate the carry
       to the next column. If there is a final
          carry after the leftmost column
                addition, discard it.
2-41




        二補數表示法的兩正數相加




2-42




                                                 21
二補數表示法的一正一負相加,且結果為正




2-43




       二補數表示法的一正一負相加,且結果為負




2-44




                             22
二補數表示法的兩負數相加




2-45




       二補數表示法的兩正數相加
       結果超過正數儲存範圍




2-46




                      23
二補數表示法的兩負數相加
       結果小於負數儲存範圍




2-47




       為何二補數可以這樣做運算
       假設是n bits
       正數 + 正數 (和一般情況一樣)
       負數(-x) + 負數(-y)
       -x在二補數表示值為 2n-x
       -y在二補數表示值為 2n-y

       2n - x + 2n - y = 2n + (2n - (x+y))

                        進位     -(x+y)的二補數表示法



2-48




                                               24
為何二補數可以這樣做運算
         正數 (x) + 負數 (-y)
         -y在二補數表示值為 2n-y
         得 2n+x-y
          (1) x >= y
             x-y為正值或0; 2n為進位
          (2) x <y
             2n+x-y = 2n-(y-x)


                        -(y-x)的二補數表示法



2-49




           Changing fractions to binary
       A floating-point number is an integer and a fraction.
       Conversion floating-point number to binary
          Convert the integer part to binary
          Convert the fraction to binary
          Put a decimal point between the two parts

           Converting the fraction part




2-50




                                                               25
Example: Transform the fraction 0.875 to binary

         Solution
        Write the fraction at the left corner. Multiply the
        number continuously by 2 and extract the integer
        part as the binary digit. Stop when the number is
        0.0.
               0.875       1.750     1.5       1.0      0.0
                       .
                 0           1        1         1



2-51




             正規化:Normalization
          A floating-point number is normalized for a simple
          representation
          Normalization: the moving of the decimal point so
          that there is only one 1 to the left of the decimal
          point.

       Original Number
        Original Number      Move            Normalized
          ------------
            ------------ ------------        ------------
         +1010001.1101                +26    × 1.01000111001
       +1010001.1101            6
          −111.000011                 −22    × 1.11000011
         -111.000011            2
        +0.00000111001                +2−6   × 1.11001
       +0.00000111001       6
          −0.001110011                −2−3   × 1.110011
         -001110011         3

2-52




                                                                26
浮點數表示法
       IEEE 754標準




2-53




       單倍精準數
       符號位元:1個位元,以0表示正數;以1表示
       負數
       指數部分:8個位元,以過剩127(Excess
       127)方式表示
       尾數部分:23個位元,從標準化的小數點後開
       始存起,不夠的位元部份補0




2-54




                                 27
實數10110.100011 的浮點數表示法

   範例
       給定一實數10110.100011,先轉換成1.0110100011×24,因為是
       正數,所以符號位元為0,其尾數部分為0110100011,指數部
       分為4,以過剩127方式儲存,必須先加上127,得131,再將
       131轉換成二進位,得10000011。因此10110.100011若按IEEE
       754標準儲存,為 01000001101101000110000000000000。




2-55




         實數-0.0010011的浮點數表示法
   範例
       -0.0010011又是如何儲存呢?先轉換成-1.0011×2 -3 ,因為是負
       數,所以符號位元為1,其尾數部分為0011,指數部分為-3,以
       過剩127方式儲存,必須先加上127,得124,再將124轉換成二
       進位,得01111100。因此-0.0010011若按IEEE 754標準儲存,
       為10111110000110000000000000000000。




2-56




                                                     28
浮點數表示法的數值
   範例
       在IEEE 754標準下,01000010100101000110000000000000所
       儲存的數值為多少呢?首先,位元符號為0,所以是正數,指
       數部分是10000101,換成十進位為133,再減去127,得6,因
       此 , 01000010100101000110000000000000 所 儲 存 的 數 值 為
       1.0010100011×26,也就是1001010.0011。。




2-57




       浮點數表示法的數值
   範例
       在IEEE 754標準下,10000010100101000110000000000000所
       儲存的數值為多少呢?首先,位元符號為1,所以是負數,指
       數部分是00000101,換成十進位為5,再減去127,得-122,
       因此,10000010100101000110000000000000所儲存的數值為
       -1.0010100011×2-122 。




2-58




                                                            29
Example: HEXADECIMAL NOTATION
       71.3125
         +1000111.0101
         +26 ×1.0001110101
         6+127=133 → 10000101
         0 10000101 00011101010000000000000
         x428EA000

2-59




       Example: IEEE 754單倍精準數表示法

       1.5
             0 01111111 10000000000000000000000
       125.625

             0 10000101 11110110100000000000000




2-60




                                                  30
ASCII及Unicode
          在電腦裡,所有的文字也存成位元字串,因此
          我們必須有公訂的對照表,以便我們能在儲存
          時將文字轉成位元字串,而在解讀時能將位元
          字串轉回文字

            ASCII
            Unicode
            Big5




2-61




       ASCI
        ASCII 全名為美國標準資訊交換碼 (American
        Standard Code for Information Interchange),是
        將英文字母、符號和數字應用數值來編碼的一套編
        碼系統
        在前面的 32 個字元是不可列印的控制字元,可從
        鍵盤中應用控制鍵結合其他鍵來執行。例如一般我
        們在文書處理應用軟體中按 Enter 鍵,游標會移到
        下一行的第1位置,即是 ASCII 第 10 號換行 (Line
        feed) 和13號歸位 (Carriage return) 的功能
        ASCII 第 27 號 Escape 則常用於印表機控制指令
        的識別符號
2-62




                                                       31
ASCII (7位元)




2-63




       BIG5 碼
        BIG5 碼是電腦處理繁體中文字的編碼系統
        由財團法人資訊策進委員會策劃制定
        BIG5 碼使用 16 位元(2Byte)的中文編碼系統,所以每
        個中文字碼均由 4 個十六進位符號組成




           15   14   13   12   11   10   9   8   7   6   5   4   3   2   1   0



                     高 位元碼                               低位 元碼




2-64




                                                                                 32
BIG5碼

       範例

            中文字   BIG-5 碼   高位元碼   低位元碼
            電      B971      B9     71
            腦      B8A3      B8     A3
            入      A44A      A4     4A
            門      AAF9      AA     F9
            一      A440      A4     40
            乙      A441      A4     41
            丁      A442      A4     42
            七      A443      A4     43




2-65




        Unicode
         萬國碼 (Unicode) 是萬國碼技術委員會 (Unicode
         Consortium,UTC) 所編定的國際性文字碼,以 ASCII
         碼為基礎,用 16 位元編碼以符合支援世界語言的編碼
         系統,因此能代表總數為 216=65,536 個的字元,對全
         世界的每個語言,加上標點符號和標準數學上的符號
         等的使用是足夠的。




2-66




                                              33
Unicode符號對照表
                            代表的字符群
           範圍
                     基本拉丁字符(與ASCII相同)
         0000-007F
                     擴充的拉丁字符
         0080-024F
                     希臘字符
         0370-03FF
                     泰文
         0E00-0E7F
                     寮文
         0E80-0EFF
                     數學符號
         2200-22FF
                     方塊圖形及幾何圖形
         2500-25FF
                     平假名及片假名
         3040-30FF
         4000-9FFF   CJK;中文、日文及韓文之漢字

2-67




                                        34

Más contenido relacionado

La actualidad más candente

Examen de-passage-developpement-informatiques-tsdi-2015-synthese-variante-2-o...
Examen de-passage-developpement-informatiques-tsdi-2015-synthese-variante-2-o...Examen de-passage-developpement-informatiques-tsdi-2015-synthese-variante-2-o...
Examen de-passage-developpement-informatiques-tsdi-2015-synthese-variante-2-o...abdelghani04
 
《姊姊的守護者》─莊佩綺製作
《姊姊的守護者》─莊佩綺製作《姊姊的守護者》─莊佩綺製作
《姊姊的守護者》─莊佩綺製作t2001ray
 
加速學習 LabVIEW 之十大密技
加速學習 LabVIEW 之十大密技加速學習 LabVIEW 之十大密技
加速學習 LabVIEW 之十大密技riobotics
 
Simon(2017) les canaux de transmission de la politique monetaire en haiti u...
Simon(2017) les canaux de transmission de la politique monetaire en haiti   u...Simon(2017) les canaux de transmission de la politique monetaire en haiti   u...
Simon(2017) les canaux de transmission de la politique monetaire en haiti u...Carl Nally Régi SIMON
 
模糊理論(Fuzzy)~電機大師黃聰亮教授演講投影片
模糊理論(Fuzzy)~電機大師黃聰亮教授演講投影片模糊理論(Fuzzy)~電機大師黃聰亮教授演講投影片
模糊理論(Fuzzy)~電機大師黃聰亮教授演講投影片vincent8899
 
Statistiquedescriptivess1 et s2
Statistiquedescriptivess1 et s2 Statistiquedescriptivess1 et s2
Statistiquedescriptivess1 et s2 Abdlhakim Fallatte
 
基本電學I第1章隨堂講義(學生本)
基本電學I第1章隨堂講義(學生本)基本電學I第1章隨堂講義(學生本)
基本電學I第1章隨堂講義(學生本)lungtengtech
 
克服團隊領導的五大障礙 (The five dysfunction of a team:a leadership fable)
克服團隊領導的五大障礙 (The five dysfunction of a team:a leadership fable)克服團隊領導的五大障礙 (The five dysfunction of a team:a leadership fable)
克服團隊領導的五大障礙 (The five dysfunction of a team:a leadership fable)周建良 Zhou Jian Liang
 
衛福部懶人包
衛福部懶人包衛福部懶人包
衛福部懶人包releaseey
 
خواص أشعة المهبط
خواص أشعة المهبطخواص أشعة المهبط
خواص أشعة المهبطHossam Sewify
 
改善提案 簡報 V 4.1
改善提案   簡報 V 4.1改善提案   簡報 V 4.1
改善提案 簡報 V 4.1joe lo
 
平衡計分卡完全教戰手冊1 4章
平衡計分卡完全教戰手冊1 4章平衡計分卡完全教戰手冊1 4章
平衡計分卡完全教戰手冊1 4章zorina5050
 
超級業務簡報學分享版
超級業務簡報學分享版超級業務簡報學分享版
超級業務簡報學分享版勝輝 周
 
PMT-008-生產管理簡介
PMT-008-生產管理簡介PMT-008-生產管理簡介
PMT-008-生產管理簡介handbook
 

La actualidad más candente (17)

Examen de-passage-developpement-informatiques-tsdi-2015-synthese-variante-2-o...
Examen de-passage-developpement-informatiques-tsdi-2015-synthese-variante-2-o...Examen de-passage-developpement-informatiques-tsdi-2015-synthese-variante-2-o...
Examen de-passage-developpement-informatiques-tsdi-2015-synthese-variante-2-o...
 
《姊姊的守護者》─莊佩綺製作
《姊姊的守護者》─莊佩綺製作《姊姊的守護者》─莊佩綺製作
《姊姊的守護者》─莊佩綺製作
 
加速學習 LabVIEW 之十大密技
加速學習 LabVIEW 之十大密技加速學習 LabVIEW 之十大密技
加速學習 LabVIEW 之十大密技
 
Simon(2017) les canaux de transmission de la politique monetaire en haiti u...
Simon(2017) les canaux de transmission de la politique monetaire en haiti   u...Simon(2017) les canaux de transmission de la politique monetaire en haiti   u...
Simon(2017) les canaux de transmission de la politique monetaire en haiti u...
 
模糊理論(Fuzzy)~電機大師黃聰亮教授演講投影片
模糊理論(Fuzzy)~電機大師黃聰亮教授演講投影片模糊理論(Fuzzy)~電機大師黃聰亮教授演講投影片
模糊理論(Fuzzy)~電機大師黃聰亮教授演講投影片
 
Statistiquedescriptivess1 et s2
Statistiquedescriptivess1 et s2 Statistiquedescriptivess1 et s2
Statistiquedescriptivess1 et s2
 
Integral table
Integral tableIntegral table
Integral table
 
基本電學I第1章隨堂講義(學生本)
基本電學I第1章隨堂講義(學生本)基本電學I第1章隨堂講義(學生本)
基本電學I第1章隨堂講義(學生本)
 
克服團隊領導的五大障礙 (The five dysfunction of a team:a leadership fable)
克服團隊領導的五大障礙 (The five dysfunction of a team:a leadership fable)克服團隊領導的五大障礙 (The five dysfunction of a team:a leadership fable)
克服團隊領導的五大障礙 (The five dysfunction of a team:a leadership fable)
 
衛福部懶人包
衛福部懶人包衛福部懶人包
衛福部懶人包
 
خواص أشعة المهبط
خواص أشعة المهبطخواص أشعة المهبط
خواص أشعة المهبط
 
106年度社區整體照顧服務體系行政說明
106年度社區整體照顧服務體系行政說明106年度社區整體照顧服務體系行政說明
106年度社區整體照顧服務體系行政說明
 
改善提案 簡報 V 4.1
改善提案   簡報 V 4.1改善提案   簡報 V 4.1
改善提案 簡報 V 4.1
 
Dom Juan, Acte V, scènes 5 et 6 : le dénouement
Dom Juan, Acte V, scènes 5 et 6 : le dénouement Dom Juan, Acte V, scènes 5 et 6 : le dénouement
Dom Juan, Acte V, scènes 5 et 6 : le dénouement
 
平衡計分卡完全教戰手冊1 4章
平衡計分卡完全教戰手冊1 4章平衡計分卡完全教戰手冊1 4章
平衡計分卡完全教戰手冊1 4章
 
超級業務簡報學分享版
超級業務簡報學分享版超級業務簡報學分享版
超級業務簡報學分享版
 
PMT-008-生產管理簡介
PMT-008-生產管理簡介PMT-008-生產管理簡介
PMT-008-生產管理簡介
 

Similar a 第2章 數位資料表示法

Fy09 Q3行動咖啡館 微軟虛擬化解決方案
Fy09 Q3行動咖啡館 微軟虛擬化解決方案Fy09 Q3行動咖啡館 微軟虛擬化解決方案
Fy09 Q3行動咖啡館 微軟虛擬化解決方案Ada Lin
 
子女教育金準備試算表
子女教育金準備試算表子女教育金準備試算表
子女教育金準備試算表5045033
 
股票、基金與外幣投資試算表
股票、基金與外幣投資試算表股票、基金與外幣投資試算表
股票、基金與外幣投資試算表5045033
 
11X1 T08 03 rules for differentiation
11X1 T08 03 rules for differentiation11X1 T08 03 rules for differentiation
11X1 T08 03 rules for differentiationNigel Simmons
 
ミクシィ決算説明資料 FY2008 2Q
ミクシィ決算説明資料 FY2008 2Qミクシィ決算説明資料 FY2008 2Q
ミクシィ決算説明資料 FY2008 2QMaki Fujita
 
د.نادية باعشن - ملتقى سيدات الأعمال الثالث
د.نادية باعشن - ملتقى سيدات الأعمال الثالثد.نادية باعشن - ملتقى سيدات الأعمال الثالث
د.نادية باعشن - ملتقى سيدات الأعمال الثالثRiyadhBWF
 
股票、基金與外幣投資試算表
股票、基金與外幣投資試算表股票、基金與外幣投資試算表
股票、基金與外幣投資試算表llykccl
 
とちぎRuby会議01(原)
とちぎRuby会議01(原)とちぎRuby会議01(原)
とちぎRuby会議01(原)Shin-ichiro HARA
 
Marketing kotler1
Marketing kotler1Marketing kotler1
Marketing kotler1fanoos2000
 
Noip 2016-day2
Noip 2016-day2Noip 2016-day2
Noip 2016-day2德源 何
 
Table 15
Table 15Table 15
Table 15HITEMY
 
Table 12
Table 12Table 12
Table 12HITEMY
 
Table 13
Table 13Table 13
Table 13HITEMY
 
銀行活定存試算表
銀行活定存試算表銀行活定存試算表
銀行活定存試算表llykccl
 
Table 14
Table 14Table 14
Table 14HITEMY
 

Similar a 第2章 數位資料表示法 (20)

Fy09 Q3行動咖啡館 微軟虛擬化解決方案
Fy09 Q3行動咖啡館 微軟虛擬化解決方案Fy09 Q3行動咖啡館 微軟虛擬化解決方案
Fy09 Q3行動咖啡館 微軟虛擬化解決方案
 
子女教育金準備試算表
子女教育金準備試算表子女教育金準備試算表
子女教育金準備試算表
 
股票、基金與外幣投資試算表
股票、基金與外幣投資試算表股票、基金與外幣投資試算表
股票、基金與外幣投資試算表
 
It Flyer Page08
It Flyer Page08It Flyer Page08
It Flyer Page08
 
11X1 T08 03 rules for differentiation
11X1 T08 03 rules for differentiation11X1 T08 03 rules for differentiation
11X1 T08 03 rules for differentiation
 
4
44
4
 
ミクシィ決算説明資料 FY2008 2Q
ミクシィ決算説明資料 FY2008 2Qミクシィ決算説明資料 FY2008 2Q
ミクシィ決算説明資料 FY2008 2Q
 
د.نادية باعشن - ملتقى سيدات الأعمال الثالث
د.نادية باعشن - ملتقى سيدات الأعمال الثالثد.نادية باعشن - ملتقى سيدات الأعمال الثالث
د.نادية باعشن - ملتقى سيدات الأعمال الثالث
 
股票、基金與外幣投資試算表
股票、基金與外幣投資試算表股票、基金與外幣投資試算表
股票、基金與外幣投資試算表
 
とちぎRuby会議01(原)
とちぎRuby会議01(原)とちぎRuby会議01(原)
とちぎRuby会議01(原)
 
Booklist
BooklistBooklist
Booklist
 
Marketing kotler1
Marketing kotler1Marketing kotler1
Marketing kotler1
 
Noip 2016-day2
Noip 2016-day2Noip 2016-day2
Noip 2016-day2
 
Table 15
Table 15Table 15
Table 15
 
Table 12
Table 12Table 12
Table 12
 
Table 13
Table 13Table 13
Table 13
 
銀行活定存試算表
銀行活定存試算表銀行活定存試算表
銀行活定存試算表
 
Manabeh
ManabehManabeh
Manabeh
 
From Virtual Worlds To The 3 D Web
From Virtual Worlds To The 3 D WebFrom Virtual Worlds To The 3 D Web
From Virtual Worlds To The 3 D Web
 
Table 14
Table 14Table 14
Table 14
 

Más de Seng Chi Ao

Más de Seng Chi Ao (11)

Hw1soln
Hw1solnHw1soln
Hw1soln
 
Hw 2 Soln
Hw 2 SolnHw 2 Soln
Hw 2 Soln
 
Hw3 Ans
Hw3 AnsHw3 Ans
Hw3 Ans
 
Hw4 Sol
Hw4 SolHw4 Sol
Hw4 Sol
 
C++
C++C++
C++
 
C++
C++C++
C++
 
第11章 電子商務
第11章 電子商務第11章 電子商務
第11章 電子商務
 
第3章 計算機組織 (Update)
第3章 計算機組織 (Update)第3章 計算機組織 (Update)
第3章 計算機組織 (Update)
 
第1章 計算機簡介
第1章 計算機簡介第1章 計算機簡介
第1章 計算機簡介
 
第4章 作業系統 (Update)
第4章 作業系統 (Update)第4章 作業系統 (Update)
第4章 作業系統 (Update)
 
第5章 網際網路 (Update)
第5章 網際網路 (Update)第5章 網際網路 (Update)
第5章 網際網路 (Update)
 

Último

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 

Último (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 

第2章 數位資料表示法

  • 1. 第2章 數位資料表示法 資料型態 二進位表示法 各種進位表示法的轉換 整數表示法 浮點數表示法 ASCII及Unicode 0與1的組合 2-2 1
  • 2. 電腦表示資料的方法 電腦以二進位方式處理資料的理由 電腦應用到電 (正電壓和 0 電壓,電的運作方式 )、磁 ( 陽極 和陰極,磁碟機的運作方式 ) 和光 ( 有反射光和無反射光, 光碟機的運作方式 ) 等性質來判斷訊號,所以對於電腦而言 二進位數字是其最能反應其物理性質的數字系統。 電腦內部是由積體電路 ( IC ) 的電子零件所組成。如圖所 示,IC 的電流狀態代表數字「01000001」。 IC 8 支針腳 0V +5V 0V 0V 0V 0V 0V +5V 8 位數的二進位 0 1 0 0 0 0 0 1 2-3 數位資訊的單位 位元(binary digit,簡稱bit)是數位資訊的基 本粒子,也是電腦儲存或傳遞資料的最小單 位,常用0或1來表示 當初電腦會採用位元表示資料,主要是因為電 子元件的穩定狀態有兩種:一種是“開”(通常用 來表示“1”)及一種是“關” (通常用來表示“0”) 電腦常以8個位元為存取單位,因此8個位元稱 為位元組(byte),一個Byte能表達28 = 256 個訊息或符號 2-4 2
  • 3. 數位資訊的單位 縮寫 大約位元 全名 精確位元組個數 範例 單位 組數 這個檔案的大 Kilo 210 = 1,024 一千(103) KB 小約238 KB。 Byte 一百萬 此大姆碟的容 Mega 20 MB 2 = 1,048,576 (106) 量為512 MB。 Byte 本片DVD的容 Giga 230 = 1,073,741,824 十億(109) GB 量為4.7 GB。 Byte 這部高容量磁 240 = Tera 一兆(1012) 碟可儲存20 TB TB Byte 1,099,511,627,776 的資料。 2-5 資料型態 數 字 文 字 資料類型 影像、圖片 語音、音樂 影片、動畫 2-6 3
  • 4. Coded and Decoded 2-7 二進位表示法 一個數字在不同的位置上所表示的數值也就不 同,如三位數“523”,右邊的“3”在個位上表示3 個一,中間的“2”在十位上就表示2個十,左邊的 “5”在百位上則表示5個百,換句話說,523 = 5 x 102 + 2 x 101 + 3 以B為基數,則dndn-1…d2d1.r1r2…rm-1rm所表示 的數為 dn x Bn-1 + dn-1 x Bn-2 + … + d2 x B1 + d1 x B0 + r1 x B-1 + r2 x B-2 + … + rm-1 x B-(m-1) + rm x B-m 二進位表示法:B=2 2-8 4
  • 5. 二進位、十進位、十六進位 2-9 各種進位表示法的轉換 二進位轉十進位 10110101.11012所對應的十進位數為181.8125 2-10 5
  • 6. 十進位整數轉二進位 十進位181所對應的二進位數為101101012 2-11 十進位小數轉二進位 十進位0.8125所對應的二進位數為0.11012 2-12 6
  • 7. 十進位0.1的二進位表示法為何? 十進位0.1所對應的二進位數為無窮位數的 0.000110011…2 2-13 十六進位 A 4-bit pattern can be represented by a hexadecimal digit, and vice versa. Bit Pattern Bit Pattern Hex Digit Hex Digit ------------ ------------ ------------ ------------ 0000 1000 0 8 0001 1001 1 9 0010 1010 2 A 0011 1011 3 B 0100 1100 4 C 0101 1101 5 D 0110 1110 6 E 0111 1111 7 F 2-14 7
  • 8. Binary to hexadecimal and Hexadecimal to binary transformation 2-15 二進位轉十六進位 二進位數換成十六進位數時,每四個位數合成一項 110110101.110112的十六進位表示法為1B5.D816 2-16 8
  • 9. 十六進位轉二進位 2-17 基底轉換法__十進位數轉換為N進位數 十進位小數轉換成十六進位小數 十進位整數轉換成十六進位數 2-18 9
  • 10. 八進位 A 3-bit pattern can be represented by an octal digit, and vice versa. Bit Pattern Bit Pattern Oct Digit Oct Digit ------------ ------------ ------------ ------------ 000 100 0 4 001 101 1 5 010 110 2 6 011 111 3 7 2-19 Binary to octal and Octal to binary transformation 2-20 10
  • 11. Taxonomy of integers 8 = 00001000 -8 11110111 11111000 2-21 整數表示法 Unsigned integer range: 0 … (2N-1) 2-22 11
  • 12. Sign-and-magnitude integers In sign-and-magnitude representation, the leftmost bit defines the sign of the number. If it is 0, the number is positive.If it is 1, the number is negative. 2-23 帶正負符號大小表示法 Range: -(2N-1-1) … +(2N-1-1) 2-24 12
  • 13. Sign-and-magnitude integers Note: There are two 0s in sign-and-magnitude representation: positive and negative. In an 8-bit allocation: +0 00000000 -0 10000000 2-25 一補數表示法 給定一個十進位數值,轉換成它的一補數表示法 步驟如下: 步驟1 先忽略其符號,將數字的部分轉成二進位數值。 步驟2 若該二進位數值超過n - 1 個位元, 則為「溢位」 (overflow),無法進行轉換;否則在它的左邊補 0,直到共有n個位元為止。 步驟3 若所要轉換的數為正數或零,則上步所得數值即 為所求;若為負數,則將每個位元做補數轉換, 原為0的轉成1;原為1的轉成0。 Range: -(2N-1-1) … +(2N-1-1) 2-26 13
  • 14. -41的一補數表示法為11010110 2-27 一補數轉十進位 如果最左邊的位元是0,則表示該數是正數,只要將 後面的位元以前面介紹的二進位轉十進位方式求出其 數值即可。 如果最左邊的位元是1,則表示該數是負數,先將每 個位元做補數轉換,原為0的轉成1;原為1的轉成0。 然後將該二進位轉成十進位,再加上一個負號即可。 範例 給定一補數11010110,因為最左邊的位元是1,所以 我們先將這補數原為0的轉成1;原為1的轉成0,得 00101001 。 再 將 二 進 位 的 00101001 轉 成 十 進 位 的 41,然後加上一個負號得-41。 2-28 14
  • 15. One’s complement integers Note: There are two 0s in one’s complement representation: positive and negative. In an 8-bit allocation: +0 00000000 -0 11111111 2-29 One’s complement integers Note: In one’s complement representation, the leftmost bit defines the sign of the number. If it is 0, the number is positive. If it is 1, the number is negative. 2-30 15
  • 16. One’s complement integers Note: One’s complement means reversing all bits. If you one’s complement a positive number, you get the corresponding negative number. If you one’s complement a negative number, you get the corresponding positive number. If you one’s complement a number twice, you get the original number. 2-31 二補數表示法 給定一個十進位數值,轉換成它的二補數表示法 步驟如下: 步驟1 先忽略其符號,將數字的部分轉成二進位數值。 步驟2 若該二進位數值超過 n-1 個位元, 則為「溢位」 (overflow),無法進行轉換;否則在它的左邊補 0,直到共有n個位元為止;若所轉換的數為 -2n- 1,則轉出來的數為1後面有n-1個0,此即為該數的 二補數表示法,不應視為溢位。 步驟3 若所要轉換的數為正數或零,則上步所得數值即為所 求;若為負數,則最右邊的那些0及最右邊的第一個1 保持不變,將其餘的每個位元做補數轉換,原為0的 轉成1;原為1的轉成0。 Range: -(2N-1) … +(2N-1-1) 2-32 16
  • 17. 40和-40的二補數表示法為何 ? 範例 40的二補數表示法為何? 第一步先將40轉成二進位 數值101000;第二步在二進位數值左邊補上0,使得 00101000共有8個位元,因為要表示的數為正數,所 以00101000即為所求。 範例 -40的二補數表示法為何? 第一步先將40轉成二進位 數值101000;第二步在二進位數值左邊補上0,使得 00101000共有8個位元;這時所要表示的數為負數, 所以最右邊的三個0及第一個1維持不變,其餘的將 原為0的轉成1;原為1的轉成0,得11011000。 2-33 Two’s complement integers 0000000000101000 1111111111011000 216-0000000000101000 0000000000101000 One’s complement 1111111111010111 10000000000000000 +1 1111111111011000 1111111111011000 -) 0000000000101000 1111111111011000 2-34 17
  • 18. Two’s complement integers Note: In two’s complement representation, the leftmost bit defines the sign of the number. If it is 0, the number is positive. If it is 1, the number is negative. 2-35 -40的二補數表示法正好是28-40 2-36 18
  • 19. 二補數轉十進位 如果最左邊的位元是0,則表示該數是正數,只要將後面的 位元以前面介紹的二進位轉十進位方式求出其數值即可。 如果最左邊的位元是1,則表示該數是負數,保留最右邊的 那些0及最右邊的第一個1,將其餘的每個位元做補數轉 換,原為0的轉成1;原為1的轉成0。然後將該二進位轉成 十進位,再加上一個負號即可。 範例 給定二補數11011000,因為最左邊的位元是1,所以 我們先保留最右邊的那三個0及最右邊的第一個1, 再將其他的位元原為0的轉成1;原為1的轉成0,得 00101000。再將二進位的00101000轉成十進位的 40,然後加上一個負號得-40。 2-37 二補數表式法位元字串與數值的對應關係 2-38 19
  • 20. Two’s complement integers Note: There is only one 0 in two’s complement: In an 8-bit allocation: 0 00000000 2-39 Two’s complement integers Note: Two’s complement can be achieved by reversing all bits except the rightmost bits up to the first 1 (inclusive). If you two’s complement a positive number, you get the corresponding negative number. If you two’s complement a negative number, you get the corresponding positive number. If you two’s complement a number twice, you get the original number. 2-40 20
  • 21. Addition in two’s complement Note: Rule of Adding Integers in Two’s Complement Add 2 bits and propagate the carry to the next column. If there is a final carry after the leftmost column addition, discard it. 2-41 二補數表示法的兩正數相加 2-42 21
  • 22. 二補數表示法的一正一負相加,且結果為正 2-43 二補數表示法的一正一負相加,且結果為負 2-44 22
  • 23. 二補數表示法的兩負數相加 2-45 二補數表示法的兩正數相加 結果超過正數儲存範圍 2-46 23
  • 24. 二補數表示法的兩負數相加 結果小於負數儲存範圍 2-47 為何二補數可以這樣做運算 假設是n bits 正數 + 正數 (和一般情況一樣) 負數(-x) + 負數(-y) -x在二補數表示值為 2n-x -y在二補數表示值為 2n-y 2n - x + 2n - y = 2n + (2n - (x+y)) 進位 -(x+y)的二補數表示法 2-48 24
  • 25. 為何二補數可以這樣做運算 正數 (x) + 負數 (-y) -y在二補數表示值為 2n-y 得 2n+x-y (1) x >= y x-y為正值或0; 2n為進位 (2) x <y 2n+x-y = 2n-(y-x) -(y-x)的二補數表示法 2-49 Changing fractions to binary A floating-point number is an integer and a fraction. Conversion floating-point number to binary Convert the integer part to binary Convert the fraction to binary Put a decimal point between the two parts Converting the fraction part 2-50 25
  • 26. Example: Transform the fraction 0.875 to binary Solution Write the fraction at the left corner. Multiply the number continuously by 2 and extract the integer part as the binary digit. Stop when the number is 0.0. 0.875 1.750 1.5 1.0 0.0 . 0 1 1 1 2-51 正規化:Normalization A floating-point number is normalized for a simple representation Normalization: the moving of the decimal point so that there is only one 1 to the left of the decimal point. Original Number Original Number Move Normalized ------------ ------------ ------------ ------------ +1010001.1101 +26 × 1.01000111001 +1010001.1101 6 −111.000011 −22 × 1.11000011 -111.000011 2 +0.00000111001 +2−6 × 1.11001 +0.00000111001 6 −0.001110011 −2−3 × 1.110011 -001110011 3 2-52 26
  • 27. 浮點數表示法 IEEE 754標準 2-53 單倍精準數 符號位元:1個位元,以0表示正數;以1表示 負數 指數部分:8個位元,以過剩127(Excess 127)方式表示 尾數部分:23個位元,從標準化的小數點後開 始存起,不夠的位元部份補0 2-54 27
  • 28. 實數10110.100011 的浮點數表示法 範例 給定一實數10110.100011,先轉換成1.0110100011×24,因為是 正數,所以符號位元為0,其尾數部分為0110100011,指數部 分為4,以過剩127方式儲存,必須先加上127,得131,再將 131轉換成二進位,得10000011。因此10110.100011若按IEEE 754標準儲存,為 01000001101101000110000000000000。 2-55 實數-0.0010011的浮點數表示法 範例 -0.0010011又是如何儲存呢?先轉換成-1.0011×2 -3 ,因為是負 數,所以符號位元為1,其尾數部分為0011,指數部分為-3,以 過剩127方式儲存,必須先加上127,得124,再將124轉換成二 進位,得01111100。因此-0.0010011若按IEEE 754標準儲存, 為10111110000110000000000000000000。 2-56 28
  • 29. 浮點數表示法的數值 範例 在IEEE 754標準下,01000010100101000110000000000000所 儲存的數值為多少呢?首先,位元符號為0,所以是正數,指 數部分是10000101,換成十進位為133,再減去127,得6,因 此 , 01000010100101000110000000000000 所 儲 存 的 數 值 為 1.0010100011×26,也就是1001010.0011。。 2-57 浮點數表示法的數值 範例 在IEEE 754標準下,10000010100101000110000000000000所 儲存的數值為多少呢?首先,位元符號為1,所以是負數,指 數部分是00000101,換成十進位為5,再減去127,得-122, 因此,10000010100101000110000000000000所儲存的數值為 -1.0010100011×2-122 。 2-58 29
  • 30. Example: HEXADECIMAL NOTATION 71.3125 +1000111.0101 +26 ×1.0001110101 6+127=133 → 10000101 0 10000101 00011101010000000000000 x428EA000 2-59 Example: IEEE 754單倍精準數表示法 1.5 0 01111111 10000000000000000000000 125.625 0 10000101 11110110100000000000000 2-60 30
  • 31. ASCII及Unicode 在電腦裡,所有的文字也存成位元字串,因此 我們必須有公訂的對照表,以便我們能在儲存 時將文字轉成位元字串,而在解讀時能將位元 字串轉回文字 ASCII Unicode Big5 2-61 ASCI ASCII 全名為美國標準資訊交換碼 (American Standard Code for Information Interchange),是 將英文字母、符號和數字應用數值來編碼的一套編 碼系統 在前面的 32 個字元是不可列印的控制字元,可從 鍵盤中應用控制鍵結合其他鍵來執行。例如一般我 們在文書處理應用軟體中按 Enter 鍵,游標會移到 下一行的第1位置,即是 ASCII 第 10 號換行 (Line feed) 和13號歸位 (Carriage return) 的功能 ASCII 第 27 號 Escape 則常用於印表機控制指令 的識別符號 2-62 31
  • 32. ASCII (7位元) 2-63 BIG5 碼 BIG5 碼是電腦處理繁體中文字的編碼系統 由財團法人資訊策進委員會策劃制定 BIG5 碼使用 16 位元(2Byte)的中文編碼系統,所以每 個中文字碼均由 4 個十六進位符號組成 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 高 位元碼 低位 元碼 2-64 32
  • 33. BIG5碼 範例 中文字 BIG-5 碼 高位元碼 低位元碼 電 B971 B9 71 腦 B8A3 B8 A3 入 A44A A4 4A 門 AAF9 AA F9 一 A440 A4 40 乙 A441 A4 41 丁 A442 A4 42 七 A443 A4 43 2-65 Unicode 萬國碼 (Unicode) 是萬國碼技術委員會 (Unicode Consortium,UTC) 所編定的國際性文字碼,以 ASCII 碼為基礎,用 16 位元編碼以符合支援世界語言的編碼 系統,因此能代表總數為 216=65,536 個的字元,對全 世界的每個語言,加上標點符號和標準數學上的符號 等的使用是足夠的。 2-66 33
  • 34. Unicode符號對照表 代表的字符群 範圍 基本拉丁字符(與ASCII相同) 0000-007F 擴充的拉丁字符 0080-024F 希臘字符 0370-03FF 泰文 0E00-0E7F 寮文 0E80-0EFF 數學符號 2200-22FF 方塊圖形及幾何圖形 2500-25FF 平假名及片假名 3040-30FF 4000-9FFF CJK;中文、日文及韓文之漢字 2-67 34