Pertemuan ke-2 - Aritmatika Komputer >>> Sistem bilangan & Format Data - Perkembangan Perangkat Keras Komputer
ARITMATIKA KOMPUTER
Materi : Englander, bab 2 dan 3 Stallings, bab 8 IEEE 754 pada website IEEE
Hubungan alami antara switch on/off dan kalkulasi menggunakan logika Boolean
On
Off
True
Yes
False
No
1
Chapter 2 Number Systems 2-3
e.g. 41=00101001
Twos compliment
Sign-Magnitude
Bit paling kiri bit penanda 0 = positif 1 = negatif +18 = 00010010 -18 = 10010010 Masalah
Perlu mempertimbangkan kedua tanda dan besaran dalam aritmatika Dua representasi nol (+0 dan -0)
Komplemen Dua
+3 = 00000011 +2 = 00000010 +1 = 00000001 +0 = 00000000 -1 = 11111111 -2 = 11111110 -3 = 11111101
Keuntungan
Satu representasi nol (00000000) Perhitungan aritmatika lebih mudah Cukup mudah menegatifkan
11111100 11111101
Range of Numbers
8 bit 2s compliment
+127 = 01111111 = 27 -1 -128 = 10000000 = -(27)
16 bit 2s compliment
+32767 = 011111111 11111111 = 215 - 1 -32768 = 100000000 00000000 = -215
Aritmatika
Asal: perhitungan menggunakan jari Digit berasal dari bahasa Latin digitus yang artinya jari Contoh : Basis 10 10 digit, 0 sampai 9
Base / Basis : angka pada beberapa digit yang berbeda termasuk nol
Binary basis 2 Bit (binary digit): 2 digit, 0 dan 1 Octal atau basis 8: 8 digit, 0 sampai 7 Hexadecimal atau basis 16: 16 digits, 0 sampai F
Examples: 1010 = A16; 1110 = B16
211
212
2-13
Number System
101 10 4 x 10
100 1 3 x1
Sum
40
215
Place Value
102 100
101 10
100 1
Evaluate
Sum
5 x 100
500
2 x 10
20
7 x1
7
216
82 64 6 x 64
81 8 2x8
80 1 4x1
384
16
217
Place Value
163 4,096
162 256
161 16
160 1
Evaluate
6x
4,096
7 x 256
0 x 16
4x1
24,576
1,792
218
1 x 128 1 x 64 128 64
2-19
1 x 128 1 x 64 128 64
2-20
R = BK where
R = range B = base K = number of digits
2-21
Digits
0+ 1+
Range
2 (0 and 1) 16 (0 to 15)
8
10 16
2+
3 4+
256
1,024 (1K) 65,536 (64K)
20
32 64
6
9+ 19+
1,048,576 (1M)
4,294,967,296 (4G) Approx. 1.6 x 1019
128
Chapter 2 Number Systems
38+
Base or Radix
Base:
The number of different symbols required to represent any given number
223
Example #1:
6516 11C16 10110 1458 28410 4348 110 01012 1 0001 11002
224
Example #2:
Counting in Base 2
Binary
Number 8s (23)
Equivalent
4s (22) 2s (21) 1s (20)
Decimal
Number
0
1 10 1 x 21
0 x 20
1 x 20 0 x 20
0
1 2
11
100 1 x 22
1 x 21 1 x 22
1 x 22 1 x 21
1 x 20 1 x 20
3
4
101
110
5
6
111
1000 1 x 23
1 x 22 1 x 23
1 x 23
1 x 21
1 x 20 1 x 20
7
8
1001
1010
9
10
2-25
1 x 21
Addition
Base Decimal Problem 6 +3 6 +1 Largest Single Digit 9
Octal
Hexadecimal Binary
6 +9 1 +0
F 1
2-26
Addition
Base Problem Carry Answer
Decimal
6 +4
6 +2 6 +A
Carry the 10
10
Octal Hexadecimal
10 10
Binary
1 +1
Carry the 2
10
2-27
Binary Arithmetic
1 1 1 1 1
1 +
1 0
1
0
0 1
0
1 0
0
1 1
0
0 1
1
1 0
1
2-28
Binary Arithmetic
Addition
Boolean using XOR and AND
+
0 1
0
0 1
1
1 10
Multiplication
AND Shift
x
0 1
0 0 00
1 00 01
229
Division
1 + 1
0
1
0
0 1 0
1 0 0
1 1 0
0 1 1
1 0 1
2-30
Binary Multiplication
Shift
Shifting a number in any base left one digit multiplies its value by the base Shifting a number in any base right one digit divides its value by the base Examples:
Binary Multiplication
1 1 1 0 0 1 1
1 1
0 0
1 1s place
2s place
4s place (bits shifted to line up with 4s place of multiplier)
1 1 0
1 0
0 1 0 0 0
1 Result (AND)
2-32
Binary Multiplication
1
x 1 1 1 1 0
1
1 0 1
0
0 1 1
1
0 1 0
1
1 0 1
0
1 1
1
0
2s place (bits shifted to line up with 2s place of multiplier) 4s place 32s place
1
1 0
1
0
0
0
1 1
0 0
0
0
1
1 0 1 1 1
0 Result (AND)
Note the 0 at the end, since the 1s place is not brought down.
2-33
2) 2) 2) Base 2
Chapter 2 Number Systems
16 ) 16 ) 16 ) 16 ) Base 16
Chapter 2 Number Systems
16 ) 16 ) 16 ) 16 ) Base 16
Chapter 2 Number Systems
82
64 x2 128
81
8 x6 48
80
1 x3 3
3,584
2-37
58 x8 464 + 6 =
Base 16
F 1111
6 0110
7 0111
Base 2 0001
Why hexadecimal?
Modern computer operating systems and networks present variety of troubleshooting data in hex format
2-39
Expressible Numbers
IEEE 754
Standard for floating point storage 32 and 64 bit standards 8 and 11 bit exponent respectively Extended formats (both mantissa and exponent) for intermediate results