• Pengertian Dasar
– Data ‡ Informasi ?
– Komunikasi
– Kode / notasi / simbol / Icon
• Bentuk Kode
– Karakter umum: Numerik & Alfabet
– Karakter khusus
1
REPRESENTASI DATA
3
REPRESENTASI DATA
5
Dibandingkan terhadap bilangan fixed-point,
bilangan floating-point mempunyai dua
keuntungan:
6
REPRESENTASI DATA
7
REPRESENTASI DATA
8
REPRESENTASI DATA
9
Unsigned Integer
– Unsigned integer hanya untuk bilangan
positif, jika negatif perlu format baru.
– Kelebihan biner
• mudah dibuat
• tidak ambigu (noise immunity)
• bisa dicopy dengan sempurna (flawlessly)
• untuk bilangan 8-bit memungkinkan 256 pola
0 & 1, sejumlah: 128 negatif + 128 positif.
10
Unsigned Integer
Unsigned variable disimpan lansung dalam format
biner
No. of Binary
bits Min Max
n 0 2n - 1
11
Unsigned Integer
No. of No. of
Type Range
bytes bits
unsigned char 1 8 0 … 255
unsigned short 2 16 0 … 65,535
unsigned int 4 32 0 … 4,294,967,295
unsigned long 4 32 0 … 4,294,967,295
12
Signed Integer
• Representasi
– Signed Integer direpresentasikan selain
oleh
nilai bilangan juga dengan adanya tambahan
tanda [negatif].
• Tipe
– Sign and Magnitude (SM)
– One’s Complement (OC)
– Two’s Complement (TC)
13
Signed Integer
• Notasi Sign Magnitude (SM)
– Format:
14
15
16
Signed Integer
• Sign Magnitude (SM):
– Penjumlahan, aturan:
sign tidak dijumlahkan, hanya magnitude
buang carry out dari msb magnitude
jumlahkan yang sign-nya sama (+ ke +
atau - ke - )
sign hasil = sign penambah
– Contoh
17
Signed Integer
– Contoh
18
Signed Integer
19
20
21
22
Signed Integer
Signed integers are generally stored in 2’s complement
format.
Most Significant Bit (MSB) is considered the sign bit
– 1 for negative numbers -- 0 for positive numbers
Binary
No. of
2’s compliment
bits
Min Max
n -2n-1 2n-1 - 1
23
Signed Data Types
No. of No. of
Type Range
bytes bits
char 1 8 -128 … 127
short 2 16 -32,768 … 32,767
int 4 32 -2,147,483,648 .. 2,147,483,647
long 4 32 -2,147,483,648 .. 2,147,483,647
24
Signed Integers
To change the sign of any number
1. Invert all the bits
2. Add 1
25
26
27
28
dibuang
29
30
31
32
33
34
BILANGAN FLOATING-POINT
Contoh :
Bilangan Mantissa Basis Eksponen
3 x 106 3 10 6
110 x 28 110 2 8
6132.784 0.6132784 10 4
34.58 0.3458 10 2
35
Mantissa dan eksponen direpresentasikan
secara eksplisit dalam komputer. Tetapi basisnya
(base) adalah yg digunakan oleh komputer
tersebut.
36
Semula penggunaan format berbeda antar
pabrik komputer untuk merepresentasikan
bilangan floating-point. Tetapi saat ini telah
digunakan format standar ANSI/IEEE secara
luas (format IEEE 754). Sedangkan IBM
mempunyai standar khusus
40
Konversi format saintifik ke format standar IEEE
41
Single precision
S E’ M
43
Contoh: Tuliskan +0.0010110… x 29 dalam format
single precision standar IEEE 754
Solusi:
0 10000101 0110…
44
Contoh: Tuliskan (0.75)10 dalam format single precision
standar IEEE
Solusi:
Sign bit, S = 1 (negatip)
0.75 x 2 = 1.5 →1
0.5 x 2 = 1.0 →1 0.11000000 = 0.11000000 x 20
0.0 x 2 = 0.0 →0
dinormalisasi = 1.100… x 21
M = 10000000000000000000000000
E=1
E’ = E + 127 = 1 + 127 = 126 = 01111110
Sehingga representasi single precision (0.75)10 :
1 01111110 10000000000000000000000
45
Latihan:
Typical 32-bit floating-point format
+1.638125 X 220 =
0 10010011 10100011010111000010100
1.638125 X 220 =
1 10010011 10100011010111000010100
+1.638125 X 2―20 =
0 01101011 10100011010111000010100
1.638125 X 2―20 =
1 01101011 10100011010111000010100
46
Latihan:
A. Tuliskan dalam format single precision
standar IEEE 754:
2. ( + 200.0 )10
3. ( - 13.275 )10
47
KODE KARAKTER
53
KODE KARAKTER
Unicode
54
KODE BINER LAIN
55
Tabel Kode Gray 4-bit
56
KODE BINER LAIN → kode desimal
(BCD, 2421, Excess-3, Excess-3 Gray)
97 = 10010111unpacked BCD
58
Penjumlahan BCD
13 = 00010011
65 = 01100101 +
78 = 01111000
1 AC
29 = 00101001
18 = 00011000 +
01000001 = 41 hasil error
0110 korektor
+
47 = 01000111
59
KODE BINER LAIN → kode desimal
(BCD, 2421, Excess-3, Excess-3 Gray)
60
Desimal 2421 Excess-3 Excess-3 Gray
0 0000 0011 0010
1 0001 0100 0110
2 0010 0101 0111
3 0011 0110 0101
4 0100 0111 0100
5 1011 1000 1100
6 1100 1001 1101
7 1101 1010 1111
8 1110 1011 1110
9 1111 1100 1010
Bit 0101 0000 0000
kombinasi 0110 0001 0001
Ini 0111 0010 0011
tidak 1000 1101 1000
digunakan 1001 1110 1001
1010 1111 1011
61
KODE BINER LAIN → kode desimal
(BCD, 2421, Excess-3, Excess-3 Gray)
62