Base-r system
X可以被表示成如下式:
X=(anan−1......a1a0a−1...a−m)r
其值可由下式計算:
X=anrn+an−1rn−1......a1r+a0+a−1r−1a−2r−2...a−mr−m
r 為進位數
Example(整數):
整數部分153
(153)10=(2×82+3×8+1×80)=(231)8
-> 輾轉相除法
Example(小數):
小數部分0.513
- 0.513 x 8 =
4
.104
- 0.104 x 8 =
0
.832
- 0.832 x 8 =
6
.656
- 0.656 x 8 =
5
.24
(0.513)10=(4×8−1+0×8−2+6×8−3+5×8−4)=(0.4065)8
-> 輾轉相乘法
Base 2i to base 2j
Example: (10111010011)2 convert to actual and hexadecimal
(10111010011)2→210711120103011→(2723)8
(10111010011)2→5101D110130011→(5D3)8
補數 Complement
base-r system:
- (r-1)'s complement
- r's complement
(r−1)′s complement of an n-digit number X=(rn−1)−X
Example(decimal systrem):
9′s complement of 546700 is
(106−1)−546700=453299
Example(binary systrem):
1′s complement of 01011000 is
(28−1)−01011000=11111111−01011000=10100111
簡單來說:0,1互換
r′s complement of an n-digit number
X={rn−X,0,if X=0if X=0
Example(decimal systrem):
10′s complement of 012398 is 987601+1=987602
Example(binary systrem):
2′s complement of 1101100 is 0010011+1=0010100
簡單來說:0,1互換外再加1
用加法器做相減(1′s−complement)
- Case:(−X)+Y:
[(2n−1)−X]+Y=(2n−1)−(X−Y)
-
If X−Y≥0 (case為負): 得到 (X−Y) 的 1′scomplement
-
If X−Y<0 (case為正): [(2n−1)−X]+Y= (進位數) 2n