Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Pertemuan-3

Aritmatika Biner
A. COMPLEMENT
a. Binary 1’s complement for
substraction
To take the 1’s complement of binary number,
Sweply change each bit. The 1’s complement
of 1 is 0 and vice versa. The 1’s complement
of 1001010 is 0110101. To substract 1’s
complement :
1. Take the 1’s complement of the subtrahend
( right/bottom number )
2. Add the 1’s complement to the minuend
( left/top number )
3. Overflow indicated that the answers is
positive. Add the overflow to the least
significant bit. This operation is called end –
around carry ( EAC ).
Lanjutan …

4.If there is no overflow then the answers is


negative. Take the 1’s complement of the
original addition to obtain the true
magnitude of the answer.
Contoh. 2-1

1. Substract 110012 – 100012

Jawab : 11001 1’s 11001


-10001 + 01110 EAC
1 00111 00111
+ 1
+
Overflow
01000

Jawabannya adalah : +01000

 Periksa : 2510 – 1710 = 810


Contoh. 2-1 ( Lanjutan )

2. Substract 100002 – 111012

Jawab : 10000 1’s 10000


11101 00010 1’s Complement
- +
10010 - 01101
No overflow

Jawabannya adalah : - 1101

 Periksa : 2510 – 2910 = -410


Binary 2’s complement for subtraction the 2’s
complement is 1’s complement and then add 1.
The 2’s complement of 10110 is 01001+1=
01010
To subtract using 2’s complement
idem 1’s complement
Contoh.
1. 10112 – 1002 =
Jawab. 1011 1011
- 0100 + 1100
overflow 10111 +0111
Jadi 10112 – 1002 = + 1112
Lanjutan …..

2. 100102 – 110002 = ……….. 2


Jawab.
10010 10010
- 11000 + 01000 2’s comp
11010 101
+ 1
No overflow
110
Jadi 100102 -110002 = - 1102
b. Operasi adder/subtracter bilangan
signed 2’sc
Jawaban adder/subtracter diindikasikan oleh
bit sign, jika jawaban positif maka bit lainnya
merupakan true magnitude dan jika negatif
maka bit lainnya merupakan bentuk 2’sc.
Contoh !
1. add untuk bilangan 8 bit 2’sc
01011001 + 10101101
Jawab. 01011001 (+89)
+ 10101101 (-83)
1 00000110 (+ 6)
Ignore
overflow Sign +
Jadi true mag = +6
2. Add 11011001 + 10101101
Jawab. 11011001 (- 39)
+ 10101101 (- 83)
1 10000110 (-122)
Ignore
overflow Sign -
2’sc
jadi true mag 10000110 1111010(-122)

3. Subtract bilangan 8 bit signed 2’sc


01011011 11100101
(+91) (-27)
Jawab.
01011011 01011011
2’sc
- 11100101 + 00011011
01110110

Sign bit +
No overflow
jadi true mag 01110110 (+118)
4. Subtract 10001010 11111100
Jawab. 10001010 2’sc 10001010
- 11111100 + 00000100
10001110

No overflow Sign bit -


2’sc
jadi true mag 10001110 01110010(-114)
2. Ubah 10010011 kedalam bilangan decimal
menggunakan sistem signed 2’sc.
Jawab.
1 0010011
2’s
Sign bit 64 32 16 8 4 2 1 = 64+32+8+4+1
1 1 0 1 1 0 1 = 109
true magnitude
Jadi true magnitude = -109
3. Tunjukkan -7810 sebagai bilangan 8 bit
signed 2’sc.
Jawab.
7810 = 0 1 0 0 1 1 1 0
128 64 32 16 8 4 2 1
true magnitude 01001110
2’sc
10110010
jadi -7810 = 10110010 (signed 2’sc).
B. BINARY CODE

Pada Binary Code Decimal ( BCD ) setiap digit


decimal direpresentasikan dengan empat bit
biner.
Contoh 2-2 Konversi bilangan decimal
ke BCD
1. 390610 = ….. BCD
Jawab :
3 9 0 6
11 1001 0000 0110

390610 = 11100100000110 BCD


Lanjutan …..

2. 543710 = ….. BCD

Jawab :
5 4 3 7
0101 0100 0011 0111

543710 = 0101010000110111 BCD


C. OTHER DECIMAL CODES
1. BCD, 2421, EXCESS–3(XS-3), 84-2-1
2. Gray Codes
3. ASCII character code

D. ERROR DETECTING CODE


Untuk mendeteksi error pada komunikasi
dan prosessing data indikasi deteksi error
untuk setiap karakter informasi / ASCII
ditambah 1 bit parity (even, odd)
Contoh.
Even parity odd parity
ASCII A = 1000001 01000001 11000001
T = 1010100 11010100 01010100
E. BINARY STORAGE AND REGISTER
Bilangan signed 2’s complement indikasi
bilangan decimal diletakkan pada Most
Significant Bit atau MSB dan bit sisanya
sebagai true magnitude.
Untuk sign bit 0 true magnitude positif
1 true magnitude negatif

Contoh !
1. Ubah 00101101 kedalam bilangan decimal
menggunakan sistem signed 2’s C.
0 0 1 01101
Sign bit 6432168421
 32 + 8 + 4 +1 = 45
Jadi true magnitude adalah +45
Soal latihan !
1. Tunjukkan bilangan biner 8 bit signed 2’sc
untuk :
a. -75 c. -150
b. +47 d. +93
2. Add bilangan 8 bit signed 1’sc dan 2’sc
a. 00011110 + 00111001
b. 00110011 + 11001000
3. Kurangkan bilangan 8 bit signed 1’sc dan
2’sc
a. 00111001 – 11001110
b. 10101010 - 10011011

You might also like