You are on page 1of 46

Sistem Sistem Bilangan, Operasi dan kode

Harry Ramza
Program Studi Teknik Elektro Fakultas Teknik Universitas Muhammadiyah Prof. Dr. HAMKA
Program Studi T. Elektro FT - UHAMKA Slide - 2 1

Tujuan Topik Bahasan


Mengulas kembali sistem bilangan desimal. Menghitung dalam bentuk bilangan biner. Memindahkan dari bentuk bilangan desimal ke biner dan dalam biner ke dalam desimal. Penggunaan operasi aritmatika pada bilangan biner. Menentukan komplemen 1 dan 2 dari sebuah bilangan biner. Dan lain lainnya..
Slide - 2 2

Program Studi T. Elektro FT - UHAMKA

Pendahuluan

Sistem Biner dan Kode kode digital merupakan dasar untuk komputer dan elektronika digital secara umum. Sistem bilangan biner seperti desimal, hexadesimal dan oktal juga dibahas pada bagian ini. Operasi aritmatika dengan bilangan biner akan dibahas untuk memberikan dasar pengertian bagaimana komputer dan jenis jenis perangkat digital lain bekerja.
Slide - 2 3

Program Studi T. Elektro FT - UHAMKA

Sistem Bilangan
Desimal Biner Oktal Hexadesimal
Program Studi T. Elektro FT - UHAMKA Slide - 2

0 0 0 0

~9 ~1 ~7 ~F
4

Bilangan Desimal

Dalam setiap bilangan desimal terdiri dari 10 digit, 0 sampai dengan 9


Contoh: Ungkapkan bilangan desimal 2745.214 sebagai penjumlahan nilai setiap digit.

Program Studi T. Elektro FT - UHAMKA

Slide - 2

Bilangan Biner

Sistem Bilangan biner merupakan cara lain untuk melambangkan kuantitas, dimana 1 (HIGH) dan 0 (LOW). Sistem bilangan biner mempunyai nilai basis 2 dengan nilai setiap posisi dibagi dengan faktor 2:

Program Studi T. Elektro FT - UHAMKA

Slide - 2

Contoh :
Konversikan seluruh bilangan biner 1101101 ke desimal
Hasil: Nilai : Biner : 26 25 24 23 22 21 20 1 1 0 1 1 0 1 = 64 + 32 + 8 + 4 + 1 = 109

1101101 = 26 + 25 + 23 + 22 + 20

Coba ini!! 1111001

Program Studi T. Elektro FT - UHAMKA

Slide - 2

Bilangan Desimal 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1

Bilangan Biner 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1
Slide - 2

22 21 20
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
8

0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1

0 0 0 0 0 1 0 2 0 0 2 1 4 0 0 4 0 1 4 2 0 4 2 1

23 22 21 20 8 0 0 0 8 0 0 1 8 0 2 0 8 0 2 1 8 4 0 0 8 4 0 1 8 4 2 0 8 4 2 1

7 8 9 10 11 12 13 14 15

Program Studi T. Elektro FT - UHAMKA

Aplikasi Digital

Ilustrasi sebuah penggunaan hitungan biner sederhana.


Program Studi T. Elektro FT - UHAMKA Slide - 2 9

Konversi Desimal ke Biner

Metode SumSum-of of-Weight. Pengulangan pembagian dengan Metode bilangan 2. Konversi fraksi desimal ke biner.

Program Studi T. Elektro FT - UHAMKA

Slide - 2

10

Metode SumSum-of of-Weight

Contoh: Bilangan desimal 9 sebagai contoh dapat diungkapkan sebagai penjumlahan nilai biner:
Program Studi T. Elektro FT - UHAMKA Slide - 2

Konversikan bilangan desimal dibawah kedalam biner: a) 12 b) 25 c) 58 d) 82


1100 11001 111010 1010010 11

Metode Pengulangan Pembagian Oleh Nilai 2


Sebuah metode sistematik memindahkan seluruh bilangan dari desimal ke biner dengan proses pengulangan pembagian dengan nilai 2.
Remainder

Konversikan bilangan desimal 12 ke dalam biner Berhenti ketika pembagian seluruh bilangan =0
Program Studi T. Elektro FT - UHAMKA

12 6 2 6 3 2 3 1 2 1 0 2

0 0 1
Slide - 2

1100
MSB LSB Konversikan bilangan desimal 39 ke dalam biner? 12

Konversi Fraksi (Bagian) Desimal ke Biner

0.625 = 0.5 + 0.125 = 2-1 + 2-3 = 0.101

Carry Berhenti ketika bagian fraksi seluruhnya nol


Program Studi T. Elektro FT - UHAMKA

MSB

LSB

. 101

0.625 x 2 = 1.25 0.25 x 2 = 0.50 0.50 x 2 = 1.00


Slide - 2

1 0 1
13

ARITMATIKA BINER

Aritmatika Biner sama halnya dengan seluruh komputerkomputer -komputer digital dan segala jenis sistem digital lainnya lainnya. . Penambahan, Pengurangan, Perkalian, dan Pembagian

Program Studi T. Elektro FT - UHAMKA

Slide - 2

14

Penambahan Biner
Empat aturan dasar penambahan digit biner (bits) berupa: 0+0=0 0+1=1 1+0=1 1+ 1 = 10 tambahkan 0 dengan carry 0 tambahkan 1 dengan carry 0 tambahkan 1 dengan carry 0 sum of 0 with a carry 0f 1 1 0 +0
Program Studi T. Elektro FT - UHAMKA

1 1 0
Slide - 2 0

Carry

1 1 0
Try This: 11 + 11 = ??
15

Pengurangan Biner
Empat aturan dasar untuk pengurangan bit seperti: 00=0 11=0 10=1 10 1 = 1 0 1 dengan sebuah pinjaman 1 1 1 0 1 = ?? 11 - 01
Program Studi T. Elektro FT - UHAMKA

Cobalah: 1 0 1 0 1 1 = ???
Slide - 2 16

10

Perkalian Biner
Empat aturan dasar untuk perkalian bit seperti : 0X0=0 0X1=0 1X0=0 1X1=1 1 1 X 1 1 = ?? 11 X 11 11 +1 1 1001
Program Studi T. Elektro FT - UHAMKA Slide - 2 17

Cobalah: 1 1 1 X 1 0 1 = ??

Pembagian Biner
Pembagian pada biner diikuti dengan prosedur yang sama sebagai pembagian dalam desimal.. 1 1 0 11 = ?? 10 11 1 1 0 11 000 Cobalah : 1 1 0 10 = ??

Program Studi T. Elektro FT - UHAMKA

Slide - 2

18

1s and 2s Complements of Binary Numbers

The 1s and 2s Complements of Binary Numbers are very important because they permit the representation of negative numbers. The method of 2s compliment arithmetic is commonly used in computers to handle negative numbers

Program Studi T. Elektro FT - UHAMKA

Slide - 2

19

Finding the 1s Complement


The 1s complement of a binary number is found by changing all 1s to 0s and all 0s to 1s. Example: 1 0 1 1 0 0 1 0 (Binary Number) 0 1 0 0 1 1 0 1 (1s Complement)

NOT Gate

Program Studi T. Elektro FT - UHAMKA

Slide - 2

20

Menentukan Komplemen ke ke-2


Komplemen ke-2 sebuah bilangan biner ditentukan dengan menambahkan 1 pada bagian LSB dari komplemen ke 1.

Tentukan komplemen ke-2 dari 10110010 10110010 + 01001101 1


Program Studi T. Elektro FT - UHAMKA

(Bilangan Biner) (Komplemen ke 1) (Add 1)


21

01001110 Slide - 2

Alternative Method to find 2s Complement

Start at the right with the LSB and write the bits as they are up and including the first 1 Take the 1s complements of the remaining bits

10111000 01001000

(Binary Number) (2s Complement)

Try This: 10010001


01101111 22

1s Complements of original bits Program Studi T. Elektro


FT - UHAMKA

These bits stay the same Slide - 2

Signed Numbers
Digital systems, such as the computer, must be able to handle both positive and negative numbers. A signed binary number consists of both sign and magnitude information. The sign indicates whether a number is positive or negative and the magnitude is the value of the number. There three forms in which signed integer (whole) numbers can be represented in binary: 1. Sign-Magnitude 2. 1s Complement 3. 2s Complement
Program Studi T. Elektro FT - UHAMKA Slide - 2 23

The Sign Bit The left-most bit in a signed binary number is the sign bit, which tells you whether the number is positive or negative.

Sign-Magnitude Form When a signed binary number is represented in signmagnitude, the left-most bit is the sign bit and the remaining bits are the magnitude bits. The magnitude bits are in true (uncomplemented) binary for both positive and negative numbers. Decimal number, +25 is expressed as an 8-bit signed binary number using signmagnitude form as:
Program Studi T. Elektro FT - UHAMKA

Sign Bit

Slide - 2

00011001

Magnitude Bit

24

1s Complement Form Positive numbers in 1s complement form are represented the same way as the positive sign-magnitude numbers. Negative numbers, however, are the 1s complements of the corresponding positive numbers. Example: The decimal number -25 is expressed as the 1s complement of +25 (00011001) as (11100110) 2s Complement Form In the 2s complement form, a negative number is the 2s complement of the corresponding positive number

Program Studi T. Elektro FT - UHAMKA

Slide - 2

25

Express the decimal number -39 in sign-magnitude, 1s complement and 2s complement

00100111
00100111 >>> 10100111

00100111

>>>

11011000

00100111
Program Studi T. Elektro FT - UHAMKA Slide - 2

>>>

11011001
26

The Decimal Value of Signed Numbers


Decimal Value of positive and negative numbers in the sign-magnitude form are Sign-Magnitude: determined by summing the weights in all the magnitude bit positions where there are 1s and ignoring those positions where there are zeros.
Determine the decimal value of this signed binary number expressed in sign magnitude: 1 0 0 1 0 1 0 1
26 25 24 23 22 21 20 0 0 1 0 1 0 1 >> 16 + 4 + 1 = 21
Program Studi T. Elektro FT - UHAMKA

The sign bit is 1: Therefore, the decimal number is -21

Slide - 2

27

The Decimal Value of Signed Numbers


1s Complement: Decimal values of negative numbers are determined by assigning a negative value to the weight of the sign bit, summing all the weight where there are 1s and adding 1 to the result
Determine the decimal values of this signed binary numbers expressed in 1s complement

00010111
-27 26 25 24 23 22 21 20 0 0 0 1 0 1 1 1
Program Studi T. Elektro FT - UHAMKA

11101000
-27 26 25 24 23 22 21 20 1 1 1 0 1 0 0 0
Slide - 2

16 + 4 + 2 + 1 = +23

-128 + 64 + 32 + 8 = -24 + 1 =28 -23

The Decimal Value of Signed Numbers


2s Complement: The weight of the sign bit in a negative number is given a negative value

Determine the decimal values of this signed binary numbers expressed in 1s complement

01010110
-27 26 25 24 23 22 21 20 0 1 0 1 0 1 1 0
Program Studi T. Elektro FT - UHAMKA

10101010
-27 26 25 24 23 22 21 20 1 0 1 0 1 0 1 0
Slide - 2

64 + 16 + 4 + 2 = +86

-128 + 32 + 8 + 2 = -86

29

Arithmetic Operations with Signed Number


In this section we will learn how signed numbers are added, subtracted, multiplied and divided. This section will cover only on the 2s complement arithmetic, because, it widely used in computers and microprocessor-based system .

Program Studi T. Elektro FT - UHAMKA

Slide - 2

30

Addition
00000111 +0 0 0 0 0 1 0 0 00001011
The Sum is Positive and is therefore in true binary 7+4

Discard Carry

00001111 +1 1 1 1 1 0 1 0 1 00001001

15 + (-6)

Program Studi T. Elektro FT - UHAMKA

The Final Carry is Discarded. 2 The SumSlide is -Positive and is therefore in true binary31

Addition
00010000 +1 1 1 0 1 0 0 0 11111000
The Sum is Negative and is therefore in 2s complement form Discard Carry 16 + (-24)

11111011 +11110111 1 11110010

-5 + (-9)

Program Studi T. Elektro FT - UHAMKA

The Final Carry is Discarded. The Sum is Negative and is therefore in Slide - 2 32 2s complement form

Subtraction
To subtract two signed numbers, take the 2s Complement of the subtrahend and ADD. Discard any final carry bit
00001000 - 00000011 8 3 = 8 + (-3) = 5 00001000 + 11111101 1 00000101
Slide - 2

Discard Cary
Program Studi T. Elektro FT - UHAMKA

2s Complement Difference
33

Multiplication
The numbers in a multiplication are the multiplicand, the multiplier and the product. Direct Addition and Partial Products are two basic methods for performing multiplication using addition. 8 X 3 = 24 8 + 8 + 8 = 24 (Decimal) 00001000 + 00001000 00010000 + 00001000 00011000

Standard Procedure
Program Studi T. Elektro FT - UHAMKA Slide - 2 34

Division
The division operation in computers is accomplished using subtraction. Since subtraction is done with an adder, division can also be accomplished with an adder. The result of a division is called the quotient.
Step 1: Determine the SIGN BIT for both DIVIDEND and DIVISOR Step 2: Subtract the DIVISOR from the DIVIDEND using 2s Complement addition to get the first partial remainder and ADD 1 to quotient. If ZERO or NEGATIVE the division is complete. Step 3: Subtract the divisor from the partial remainder and ADD 1 to the quotient. If the result is POSITIVE repeat Step 2 or If Slide ZERO or NEGATIVE the division is Program Studi T. Elektro -2 35 FT - UHAMKA complete.

Hexadecimal Numbers

Most digital systems deal with groups of bits in even powers of 2 such as 8, 16, 32, and 64 bits. Hexadecimal uses groups of 4 bits. Base 16

16 possible symbols 0-9 and AA-F

Allows for convenient handling of long binary strings.


Slide - 2 36

Program Studi T. Elektro FT - UHAMKA

Hexadecimal Numbers

Convert from hex to decimal by multiplying each hex digit by its positional weight. Example:

16316 1 (16 2 ) 6 (161 ) 3 (160 ) 1 256 6 16 3 1 35510


Program Studi T. Elektro FT - UHAMKA Slide - 2 37

Hexadecimal Numbers

Convert from decimal to hex by using the repeated division method used for decimal to binary and decimal to octal conversion. Divide the decimal number by 16 The first remainder is the LSB and the last is the MSB.

Note, when done on a calculator a decimal remainder can be multiplied by 16 to get the result. If the remainder is greater than 9, the letters A through F are used.
Slide - 2 38

Program Studi T. Elektro FT - UHAMKA

Hexadecimal Numbers

Example of hex to binary conversion:

Program Studi T. Elektro FT - UHAMKA

Slide - 2

39

Hexadecimal Numbers

Program Studi T. Elektro FT - UHAMKA

Slide - 2

40

Hexadecimal Numbers
Hexadecimal is useful for representing long strings of bits. Understanding the conversion process and memorizing the 4 bit patterns for each hexadecimal digit will prove valuable later.

Program Studi T. Elektro FT - UHAMKA

Slide - 2

41

BCD
Binary Coded Decimal (BCD) is another way to present decimal numbers in binary form. BCD is widely used and combines features of both decimal and binary systems. Each digit is converted to a binary equivalent.

Program Studi T. Elektro FT - UHAMKA Slide - 2 42

BCD

To convert the number 87410 to BCD: 8 7 4 1000 0111 0100 = 100001110100BCD

Program Studi T. Elektro FT - UHAMKA

Each decimal digit is represented using 4 bits. Each 44-bit group can never be greater than 9. 9. Reverse the process to convert BCD to decimal.
Slide - 2

43

BCD
BCD is not a number system. BCD is a decimal number with each digit encoded to its binary equivalent. A BCD number is not the same as a straight binary number. The primary advantage of BCD is the relative ease of converting to and from decimal.

Program Studi T. Elektro FT - UHAMKA Slide - 2 44

Alphanumeric Codes

Represents characters and functions found on a computer keyboard. ASCII American Standard Code for Information Interchange.

Seven bit code: 27 = 128 possible code groups Table 22-4 lists the standard ASCII codes Examples of use are: to transfer information between computers, between computers and printers, and for internal storage.
Slide - 2 45

Program Studi T. Elektro FT - UHAMKA

Thank You
Buku yang selalu dibaca tidak akan mengumpul habuk dan debu. Berjinaklah dengan buku kerana ia adalah teman yang paling berguna menimba ilmu

Program Studi T. Elektro FT - UHAMKA

Slide - 2

46

You might also like