Representasi Data, SISTEM BILANGAN, KODE BILANGAN

AlhanAhmad2 44 views 38 slides Jun 24, 2024
Slide 1
Slide 1 of 38
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38

About This Presentation

tentang pengantar rangkaian sequensial


Slide Content

REPRESENTASI DATA
 SISTEM BILANGAN
 KODE BILANGAN

Data Types & Representations
Tipe data dalam sistem digital adalah
dalam format binary.
• Tiga kategori data:
 Angka untuk operasi aritmetika
 Huruf untuk representasi data
 Simbol, mis: untuk fungsi kontrol
VOLT

Positional Number System
Numbers consist of a bunch of digits, each with a weight:
1 6 2 . 3 7 5 Digits
100 10 1 1/10 1/100 1/1000 Weights

The weights are all powers of the base, which is 10. We can rewrite
the weights like this:
1 6 2 . 3 7 5 Digits
10
2
10
1
10
0
10
-1
10
-2
10
-3
Weights

• To find the decimal value of a number, multiply each digit by its
weight and sum the products.
(1 x 10
2
) + (6 x 10
1
) + (2 x 10
0
) + (3 x 10
-1
) + (7 x 10
-2
) + (5 x 10
-
3
) = 162.375

Base / Radix
•D = d
1d
0.d
-1d
-2
•D = d
1⋅10
1
+ d
0 ⋅10
0
+ d
-1 ⋅10
-1
+ d
-
2 ⋅10
-2
m-1
D = ∑ d
i r
i
n=1

Converting binary to decimal
We can use the same trick to convert binary, or
base 2, numbers to decimal. The only difference is
that the weights are powers of 2.
• For example, here is 1101.01 in binary:
• The decimal value is:
1 1 0 1 . 0 1 Binary digits, or bits
2
3
2
2
2
1
2
0
2
-1
2
-2
Weights (in base 10)
(1 x 2
3
) + (1 x 2
2
) + (0 x 2
1
) + (1 x 2
0
) + (0 x 2
-1
) + (1 x 2
-2
) = 8 +
4 + 0 + 1 + 0 + 0.25 = 13.25

Converting decimal to binary
•To convert a decimal integer into binary, keep dividing by 2 until the
quotient is 0. Collect the remainders in reverse order.
•To convert a fraction, keep multiplying the fractional part by 2 until it
becomes 0. Collect the integer parts in forward order.
•Example: 162.375:





•So, 162.375
10 = 10100010.011
2

Why does this work?
This works for converting from
decimal to any base
Why? Think about converting
162.375 from decimal to decimal.
Each division strips off the
rightmost digit (the remainder).
The quotient represents the
remaining digits in the number.
162 / 10 = 16 rem 2
16 / 10 = 1 rem 6
1 / 10 = 0 rem 1
Similarly, to convert fractions, each
multiplication strips off the leftmost
digit (the integer part). The
fraction represents the remaining
digits.
0.375 x 10 = 3.750
0.750 x 10 = 7.500
0.500 x 10 = 5.000

Base 16 is useful too
Thehexadecimal system uses 16
digits:
0 1 2 3 4 5 6 7 8 9 A B C D E F
You can convert between base 10
and base 16 using techniques like
the ones we just showed for
converting between decimal and
binary.
For our purposes, base 16 is most
useful as a “shorthand” notation
for binary numbers.
Since 16 = 2
4
, one
hexadecimal digit is equivalent
to 4 binary digits.
It’s often easier to work with a
number like B4 instead of
10110100.
Hex is frequently used to specify
things like IPv6 addresses and 24-
bit colors.

Binary and hexadecimal
conversions
•Converting from hexadecimal to binary is easy: just replace
each hex digit with its equivalent 4-bit binary sequence.
261.35
16 = 2 6 1 . 3 5
16
= 0010 0110 0001 . 0011 0101
2
•To convert from binary to hex, make groups of 4 bits,
starting from the binary point. Add 0s to the ends of the
number if needed. Then, just convert each bit group to its
corresponding hex digit.
10110100.001011
2 = 1011 0100 . 0010 1100
2
• = B 4 . 2 C
16

Konversi Binary ke Hexadecimal
1010011100
2 = (29C)
16
10.10111
2 = ( 2,B8)
16

Base 8 - Octal
•Theoctal system uses 8 digits:
0 1 2 3 4 5 6 7
•Earlier in this history of
computing, octal was used as a
shorthand for binary numbers.
(Now hexadecimal is more
common.)
•Since 8 = 2
3
, one octal digit is
equivalent to 3 binary digits.
–Numbers like67 are easier to
work with than 110111.
–Can use a conversion table, just
like we did with hexadecimal.
•Still shows up in some places. For
instance, file access permissions in
•Unix file systems.

Konversi Octal ke Binary
765
8 = ( 111 110 101 )
2
7.432
8 = ( 111…100 011 010 )
2

Konversi Hexadesimal ke Octal/Binary
9FB
16 = (1001 1111 1011 )
2
4.C8A
16 = ( 4.6212 )
8 (110 010 001 010)
 000 100
(7B.7A)
16 = 001 111 011.011 110 100
 173.364

Number Systems Summary
Computers are binary devices.
We’re forced to think in terms of base 2.
Today we learned how to convert numbers between
binary, decimal and hexadecimal.
We’ve already seen some of the recurring
themes of architecture:
We use 0 and 1 as abstractionsfor analog voltages.
We showed how to representnumbers using just
these twosignals.
Next we’ll introduce special operations for binary
values and show how those correspond to
circuits.

Addition and Subtraction of Binary
Numbers
Arithmetic is the most basic thing you can do
with a computer.
These next few lectures focus on additionand
subtraction.
Computers were designed to compute, so
arithmetic is at the heart of a CPU.

Binary addition by hand
•the right, just as you add two decimal numbers.
•But remember that it’s binary. For example, 1 + 1 = 10
and you have to carry!

Subtraction
The arithmetic we did so far was limited to
unsigned (positive) integers.
Now we’ll consider negative numbers and
subtraction.
–The main problem is representing negative numbers in
binary.
We introduce three methods, and show why one
of them is the best.
–With negative numbers, we’ll be able to do subtraction
using the adders we made last time, because A - B = A
+ (-B).

Unsigned Numbers
Min and Max dari bilangan:
2 bit min = 0
10 ; max = 3
10
4 bit min = 0
10 ; max = 15
10
n bit min = 0
10 ; max = 2n – 1
(10)

Bilangan Negatif
Sign-magnitude system:
MSB menyatakan positif atau negatif
1 = - (negatif)
0 = + (positif)
0101
2 = +5
10
1101
2 = -5
10

Sign-magnitude system
Ada dua representasi 0
00000 dan 10000
n bit bilangan:
-(2
n-1
-1) sampai (2
n-1
-1)
4 bit bilangan:
min: -(2
3 - 1
) = -7
max: (2
3 - 1
) = 7

Operasi Aritmetika
Sign-magnitude system
Jika tanda sama, penjumlahan secara
normal.
Jika tanda berbeda, bandingkan nilai kedua
operand:
jika sama, maka hasilnya 0.
jika beda, kurangkan nilai kecil dari nilai
besar, tanda hasil mengikuti nilai besar.

Operasi Aritmetika
Sign-magnitude system
Perkalian dilakukan dengan penjumlahan
berulang.
Pembagian dilakukan dengan
pengurangan berulang.
Proses pembandingan tanda operand
memperlambat proses.
Muncul complement number
system

Perkalian Binary
Shift-and-add method
multiplicand (14)
multiplier (13)







product (182)

Pembagian Binary

Complement 2 System
•Komplemen 1 ditambah 1
•Komplemen 2 dari 100110=
011001 +1 =011010
•complement 2 dari 100110 =
1000000 - 100110 = 011010 (2’s
complement)
•complement 2 dari 1011001 =
10000000 - 1011001 = 0100111 (2’s
complement)
•complement 2 dari bilangan
binary disebut two’s
complement

KOMPLEMEN 1
•Komplemen 1
•Membalik 0 menjadi 1
•Dan membalik 1 menjadi 0

•Contoh
•Komplemen 1 dari 110110= 001001

•Representasi bilangan negatif
diperoleh dari bilangan positif
dikomplemenkan termasuk sign
bit kemudian ditambah 1.
•Mendapatkan two’s complement
dengan mengubah semua 1
menjadi 0 dan semua 0 menjadi 1,
kemudian ditambahkan 1.
•Buang carryjika ada!

Komplemen 1 dari 1001101 = 0110010


Two’s complement dari 10011010 =
01100101 +1 = 01100110

Radix-Complement System

Two’s complement
Representasi bilangan negatif diperoleh
dari bilangan positif di-komplemen-kan
termasuk sign bit kemudian ditambah 1.
Mendapatkan two’s complement dengan
mengubah semua 1 menjadi 0 dan semua
0 menjadi 1, kemudian ditambahkan 1.
Buang carryjika ada!

Two’s complement
Untuk 4 bit numbers:
– minimal: -2
3
= -8
–maximal: 2
3
- 1 = 7
Dengan m-bit, dapat direpresentasikan
bilangan dari - (2
m-1) sampai +(2
m-1 -1).

Kelebihan Two’s Complement
•Penjumlahan dan pengurangan binary
numbers dapat disederhanakan dengan
satu rangkaian logika, baik signed ataupun
unsigned integers.
•Representasi urutan bilangan two’s
complement diperoleh dengan selisih 1. (
carry diabaikan!)

Pengurangan Two’s Compl
•Pengurangan dilakukan dengan menjumlahkan
minuend (yang dikurangi) dengan two’s
complement dari subtrahend (pengurang).
•Buang carry jika ada!

Operasi penjumlahan dan
pengurangan two’s complemen

Rule
Overflow terjadi bila hasil operasi
melebihi rentang nilai bilangan.
Penjumlahan dua bilangan berbeda tanda
tidak akan pernah menghasilkan overflow.
Penjumlahan dua bilangan yang tandanya
sama dan menghasilkan jumlah yang
melebihi bilangan terbesar yang bisa
direpresentasikan.

Untuk penjumlahan dua bilangan
yang bertanda sama:
“Jika tanda hasil berbeda dengan
tanda operand”
Tags