Professional Documents
Culture Documents
Type Data
1.
2.
3.
Representasi Radix
Radix atau basis: adalah jumlah
simbol yang digunakan untuk mewakili
nilai. Sebuah sistem jumlah radix r
menggunakan string yang terdiri dari
simbol r yang berbeda untuk mewakili
nilai.
Radix representation of
numbers
Binary Numbers
Example
1.
22
21
20
2-1
2-2
1 x 22 + 0 x 2 + 1 + 0 x 2-1 + 1 x 2-2
4+
0+
1+
0+
1/22 = 5.25
(101.01)2 (5.25)10
Binary Addition
Example Add (11110)2 to
(10111)2
1 1 1 1
1 1 1 0 1
+
1 0 1 1 1
--------------------1 0 1 0 1 0 0
carry
(111101)2 + (10111) 2 = (1010100)2
1
1
1
carries
Binary Subtraction
1
0 10 10
1
1+1=
2
10
0 0 10
0 1 1 0 1
1 0 1 1 1
-----------------------0 1 1 0 1 1 0
(1001101)2 - (10111)2 = (0110110)2
borrows
2n
20=1
21=2
2
3
4
5
22=4
23=8
24=16
25=32
6
7
26=64
27=12
8
n
8
2n
28=256
9
10
29=512
210=102
4
211=204
8
212=409
6
220=1M
230=1G
240=1T
11
12
20
30
40
Mega
Giga
Tera
Octal Numbers
Counting in Octal
0
10 11 12 13 14 15 16 17
20 21 22 23 24 25 26 27
Decimal(base 10)
Binary(base 2)
Hexadecimal
(base16)
Integer
Quotient
13/2 =
6/2 =
3/2 =
1/2 =
Remainder
(12+1)
( 6+0 )
(2+1 )
(0+1)
Coefficient
a0 = 1
a1 = 0
a2 = 1
a3 = 1
1
0
1
Fraction
+
+
+
0.25
0.50
0
Coefficient
a-1 = 1
a-2 = 0
a-3 = 1
remainder
1
0
0
1
0
1
Closer to
the point
Overflow
Fraction
X by 2
.6875
.3750
.750
.5
175/8 =
21/8 =
2/8 =
21
2
0
Remainder
+
+
+
7/8
5/8
2/8
Coefficient
a0 = 7
a1 = 5
a2 = 2
0.3125 x 8 =
0.5000 x 8 =
2
4
+
+
Fraction
Coefficient
0.5
0
a-1 = 2
a-2 = 4
Overflow of
multiplication
Hexadecimal Numbers
(0,1,2,3,4,5,6,7,8,9,A, B, C, D, E, F)
(1110) 2 = (E)16
(1110) 2
Example
remainde
r
107
Divide/16
11=B
Closer to
.
the period
Overflow
Fraction
X by 16
.
00390625
.0625
.0000
(107.00390625)10 (6B.01)16
Conversion is easy!
Determine 4-bit value for each hex digit
352378 =
Example
Convert 101011110110011 to
a.
octal number
b. hexadecimal number
a.
5
3
6
6
3
101011110110011 = (53663)8
b. Each 4 bits are converted to hexadecimal:
(0101) (0111) (1011) (0011)
5
7
B
3
101011110110011 = (57B3)16
Conversion from binary to hexadecimal is similar except that the bits
divided into groups of four.
0000
0001
0010
0011
0100
5
6
7
8
9
0101
0110
0111
1000
1001
Used in early
computers (40s, 50s)
Used to encode
numbers for sevensegment displays.
Easier to read?
(Example)
The decimal 99 is represented
by 1001 1001.
Gray Code
Digit
Binary
Gray Code
0000
0000
0001
0001
0010
0011
0011
0010
0100
0110
0101
0111
0110
0101
0111
0100
1000
1100
1001
1101
10
1010
1111
11
1011
1110
12
1100
1010
13
1101
1011
14
1110
1001
15
1111
1000
ASCII Code
Decimal
Octal
1000001
41
65
101
1000010
42
66
102
1000011
43
67
103
Z
a
Complements
Complements of numbers
(r-1 )s Complement
Given a number N in base r having n digits,
the (r- 1)s complement of N is defined as
(rn - 1) - N
For decimal numbers the
base or r = 10 and r- 1= 9,
so the 9s complement of N
is
(10n-1)-N
99999. - N
Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
9s complement Examples
ls complement
For binary numbers, r = 2 and r 1 = 1,
r-1s complement is the ls complement.
The ls complement of N is (2n - 1) - N.
Bit n-1
Bit n-2
Bit 1
Bit 0
Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
ls complement
Find r-1 complement for binary number N with four binary digits.
r-1 complement for binary means 2-1 complement or 1s complement.
n = 4, we have 24 = (10000)2 and 24 - 1 = (1111)2.
The ls complement of N is (24 - 1) - N. = (1111) - N
ls complement
The complement 1s of
1011001 is 0100110
The 1s complement of
0001111 is 1110000
rs Complement
Given a number N in base r having n digits,
the rs complement of N is defined as
rn - N.
For decimal numbers the
base or r = 10,
1
Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
2s complement
For binary numbers, r = 2,
rs complement is the 2s complement.
The 2s complement of N is 2n - N.
Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
2s complement Example
1
The 2s complement of
1011001 is 0100111
The 2s complement of
0001111 is 1110001
Method 1:
The 2s complement of binary number is obtained by adding 1 to the
ls complement value.
Example:
1s complement of 101100 is 010011 (invert the 0s and 1s)
2s complement of 101100 is 010011 + 1 = 010100
Examples
Finding the 2s complement of (01100101)2
[N]
=01100101
=10011011
MN
rs complement
add M to ( rn N ) :
(rn N )
Sum = M + ( r n N)
Example 2;
Now consider an example with M <N.
The subtraction 13250 - 72532 produces negative 59282. Using
the procedure with complements, we have
M = 13250
10s complement of N = +27468
Sum = 40718
Take 10s complement of Sum
100000
-40718
The number is :
59282