雖然玉瑄今天早上被我搞得一頭霧水....
我也被自己搞得一頭霧水....
不過回家之後我查了以前的講義...
就大概講一下二進位(binary)的東西好了...
不懂的就只好再聯絡了...
1.complement number
算法是把0<==>1互換,就可以了.至於要算回decimal,就一個一個加吧..
這部份應該沒問題..
2.2'complement number
平常說complement number 是說上面那一種,如果要說到2的補數,一定
要先說明清楚.2的補數是拿來做負數用的,相對於unsigned,把0<==>1互
換之後,還要再加1(這代表的是負數),之後計算回decimal的方法跟上面
一樣,只是算好以後還要加一個負號...
3.why complement numbers?
這我也不知道...不過雖然說 00000000 在某些時候等同於 11111111
不過計算時還是就照帳面上算就好了...不用再把它補回來...
ex1.
give the complement of 10101010
==>01010101
==>85
ex2.
give the 2's complement of 10101010
==>01010110
==>-86
大概就這樣子...小豪你說對不對...
--
The only thing they bequeathed to him was a fear of women.
desired but feared them.Needing to create a compromise
between fear and desire,he devised what he called "erotic
friendship"...
adapted from The Unbearable Lightness of Being,Milan Kundera
--
※ 發信站: 批踢踢實業坊(ptt.twbbs.org)
◆ From: tp241-80.seed.net.tw