Pertemuan 8 KTI

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 51

Data Representation

Data Representation
• How do computers represent data?
 Most computers are digital
 Recognize only two
discrete states: on or off
 Use a binary system to
recognize two states
 Use number system with
two unique digits: 0 and 1,
called bits (short for
binary digits)
 Smallest unit of data
computer can process
Data Representation
• What is a byte?
 Eight bits grouped together as a unit
 Provides enough different combinations of 0s and 1s
to represent 256 individual characters
 Numbers
 Uppercase
and lowercase
letters
 Punctuation
marks
Converting Binary to Decimal
• Decimal number system is base 10
– 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
– Uses 10 numbers
Power of 10
representation 1023,625
4
103 102 101 100

Decimal
representation 10000 1000 100 10 1

Base 10 20,000 3,000 600 20 5


representation
Converting Binary to Decimal
Binary number system is base 2
 0, 1
 Uses 2 numbers
10010001 = 145

Base 2
representation 27 26 25 24 23 22 21 20
Decimal
representation 128 64 32 16 8 4 2 1

Base 2
representation 1 0 0 1 0 0 0 1
Converting Decimal to Binary
Convert decimal 35 to binary
1.Using 8 bits, find largest power of 2 that will “fit”
into 35
2.Place a 1 into that slot
3.If the # doesn’t fit, place a 0 into that slot
Power of 2
representation 27 26 25 24 23 22 21 20
Decimal 128 64 32 16 8 4 2 1
representation
Base 2
representation 0 0 1 0 0 0 1 1

35 = 00100011
Convert Binary to Decimal
1. Choose an 8 bit binary number = 10101110
2. Write the binary digits under the correct column
3. For each column with a 1, you will add that decimal
value
4. You will not add the values of the columns you entered
Power of 2
0
representation 27 26 25 24 23 22 21 20
Decimal
representation 128 64 32 16 8 4 2 1

Base 2
1 0 1 0 1 1 1 0
representation

128 + 32 + 8 + 4 + 2 = 174 10101110 = 174


Data Representation
•What are three popular coding systems to represent
data?
 ASCII—American Standard Code for Information Interchange
 EBCDIC—Extended Binary Coded Decimal Interchange Code
 Unicode—coding scheme capable of representing all
world’s languages

ASCII Symbol EBCDIC


00110000 0 11110000
00110001 1 11110001
00110010 2 11110010
00110011 3 11110011
Data Representation
• How is a letter converted to binary form and
back? Step 1.
The user presses Step 2.
the capital letter An electronic signal for the
D (shift+D key) capital letter D is sent to the
on the keyboard. system unit.

Step 4. Step 3.
After processing, the binary The signal for the capital letter D
code for the capital letter D is is converted to its ASCII binary
converted to an image, and code (01000100) and is stored in
displayed on the output device. memory for processing.
Memory Seat #2B4 Seat #2B3
• What is memory?
 Electronic components that
store instructions, data, and
results
 Consists of one or
more chips on
motherboard or
other circuit board
 Each byte stored
in unique location
called an address,
similar to addresses
on a passenger train
Memory
 Stores three basic categories of items:
1.OS and system software
2.Application programs
3.Data and information
 Byte is basic storage unit in memory
 To access data or instructions in memory,
computer references the address that
contain the bytes of data
 Manufacturers state the size of memory
and storage devices in terms of number of
bytes available
Memory
• How is memory measured?
 By number of bytes available for storage
 KB = 1024 bytes

Term Abbreviation Approximate Size


Kilobyte KB or K 1 thousand bytes
Megabyte MB 1 million bytes
Gigabyte GB 1 billion bytes
Terabyte TB 1 trillion bytes
Name Abbr. Size

Kilo K 2^10 = 1,024

Mega M 2^20 = 1,048,576

Giga G 2^30 = 1,073,741,824

Tera T 2^40 = 1,099,511,627,776

Peta P 2^50 = 1,125,899,906,842,624

Exa E 2^60 = 1,152,921,504,606,846,976

Zetta Z 2^70 = 1,180,591,620,717,411,303,424

Yotta Y 2^80 = 1,208,925,819,614,629,174,706,176


Number Systems

Number systems are very important to understand


because the design and organization of a computer
depends on the number systems. The four kind of number
system used by the digital computer –
1.Decimal number system
2.Binary number system
3.Octal number system
4.Hexadecimal number system
Decimal Number System

The decimal number system consists of 10 digits namely 0 to 9.


Since the decimal number system consists of 10 digits, the base or radix of
this system is 10.
e.g (405)10 , (145.25)10
Octal Number System

The octal number system consists of 8 digits namely 0 to 7.


Since the Octal number system consists of 8 digits, the base or radix of this
system is 8.
e.g (76)8 , (55.25)8
Binary Number System

The binary number system consists of 2 digits namely 0 and 1.


Since the binary number system consists of 2 digits, the base or radix of this
system is 2.
e.g (101)2 , (1001.11)2
Hexadecimal Number System

The Hexadecimal number system, popularly known as Hex system has 16


symbols, therefore its base/radix in 16.
The 16 symbols used in Hexadecimal system are
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
e.g (45)16, (11A)16
Conversion between Number
Systems

Decimal into Binary


Step 1. Divide the decimal number by the base of binary using the repeated-
division method.
Step 2. Note the remainder separately.
Step 3. Arrange the remainder in an order where the first remainder noted is
LSD and the last remainder is MSD.
Conversion between Number
Systems
Decimal into Binary (Contd…)
Conversion between Number
Systems

Decimal into Octal


Step 1. Divide the decimal number by the base of octal using the repeated-
division method.
Step 2. Note the remainder separately.
Step 3. Arrange the remainder in an order where the first remainder noted is
LSD and the last remainder is MSB.
Conversion between Number
Systems

Decimal into Octal (Contd…)


Conversion between Number
Systems

Decimal into Hexadecimal


Step 1. Divide the decimal number by the base of Hexadecimal using the
repeated-division method.
Step 2. Note the remainder separately.
Step 3. Arrange the remainder in an order where the first remainder noted is
LSD and the last remainder is MSB.
Conversion between Number
Systems

Decimal into Hexadecimal (Contd…)

16

16
Conversion between Number
Systems
Decimal real number into Binary, Octal and Hexadecimal

Step 1. Multiply the fractional part by the base of the numbers system (2, 8 or
16).
Step 2. Remove the whole number from the product (the result of the
multiplication) and collect it separately.
Step 3. Repeat the step 1 and 2 with the new fractional part till the fractional
part becomes zero.
Conversion between Number
Systems
Binary to Decimal

Any binary number can be converted into decimal number using the weights
assigned to each bit.
e.g. (11011)2
Its decimal equivalent is
1x24+1x23+0x22+1x21+1x20 = (27)10
Conversion between Number
Systems
Binary to Octal

1.Indirect Method:
Binary  Decimal  Octal
e.g. (11011)2
Its decimal equivalent is
1x24+1x23+0x22+1x21+1x20 = (27)10
(division method)
And its Octal equivalent is (33)8
Conversion between Number
Systems
Binary to Octal (Contd…)

2. Direct Method
Binary  Octal
Step 1: Make the group of 3-bits from right to left for integer from left
to right for fraction.
Step 2: Find decimal equivalent of each group.

Note: if the left most group (in integer) and the right most group (in
fraction) present with less than 3-bits make that group by adding one
or two zeros.
Conversion between Number
Systems
Binary to Octal (Contd…)

Direct Method: e.g.

Binary  Octal
e.g. (101111)2 = (? )8
(101111)2 = (57)8
Conversion between Number
Systems
Binary to Hexa

1.Indirect Method:
Binary  Decimal  Hexa
e.g. (11011)2
Its decimal equivalent is
1x24+1x23+0x22+1x21+1x20 = (27)10
And its Hexa equivalent is (1B)16 (Division method)
Conversion between Number
Systems
Binary to Hexa

2. Direct Method:
Binary  Hexa
Step 1: Make the group of 4-bits from right to left for integer from left
to right for fraction.
Step 2: Find decimal equivalent of each group.

Note: if the left most group (in integer) and the right most group (in
fraction) present with less than 4-bits make that group by adding one,
two or three zeros.
Conversion between Number
Systems
Binary to Hexa

Direct Method: e.g.

Binary  Hexa
e.g. (101111)2 = (? )16
(0010 1111)2 = (215)16 = (2F)16
Conversion between Number
Systems
Octal to Decimal

Any octal number can be converted into decimal number using the weights
assigned to each bit.
e.g. (75)8
Its decimal equivalent is
7x81+5x80 = (61)10
Conversion between Number
Systems
Octal to Binary

Any octal number can be converted into binary


number by converting each bit of octal into its
equivalent 3-bit binary number.
e.g. (75)8
Its binary equivalent is (111101)2
Conversion between Number
Systems
Octal to Hexa

Octal  Binary  Hexa


Step1. Convert each digit of the octal into its 3 bit binary
equivalent.
Step2. Combine all the 3-bit binary equivalents to form
the entire binary sequence.
Step3. Make group of 4 bits staring from LSD. The extra
zeros for the completion of a group are placed at the
leftmost end of the number.
Step 4. Convert each of the 4-bit groups into their
hexadecimal equivalents.
Conversion between Number
Systems
Octal to Hexa (Contd…)

Octal  Binary  Hexa


Conversion between Number
Systems
Hexa to decimal
Conversion between Number
Systems
Hexa to binary
Binary representation of integers

Binary equivalent of the integers are stored in memory including one


additional bit for representing the sign of integers (positive or negative).
If the binary equivalent of the integer includes one additional bit for
representing its sign, that binary number is called signed binary
number.
Binary representation of integers

There are three ways for representing the positive and negative integers into
its binary equivalent.
1.Sign magnitude representation
2.One’s Complement
3.Two’s Complement
Binary representation of integers

1.Sign magnitude representation


In the sign magnitude representation, positive number have a additional bit
(sign bit) 0, while the negative number has a sign bit 1, while the magnitude is
a simple binary equivalent of the number.
E.g. +5 and -5 can be representing in 6 bit register as:
+5 = 0 00101 and -5 = 1 00101
Binary representation of integers

Note: In every representation


technique , the representation of
positive number is identical to that
used in the sign magnitude system
i.e simple binary form including
sign bit 0.
Binary representation of integers

2. One’s Complement representation


In one's complement, positive numbers are represented as usual in signed
magnitude. However, negative numbers are represented differently. To negate a
number, replace all zeros with ones, and ones with zeros - flip the bits.
+12 = 0 0001100, and -12 = 1 1110011.
Binary representation of integers

3. Two’s Complement representation


In two's complement, positive numbers are represented as usual in signed
magnitude. However, negative numbers are represented by adding 1 in magnitude
part of one’s complement.
+12= 0 0001100
-12 = 1 1110011 (1’s complement)
-12 = 1 1110100 (2’s complement)
Binary Addition

Rule for Binary Addition:

0+0=0
0+1=1
1+0=1
1 + 1 = 0 (Carry 1)
Binary Addition

Example:

Add 110101 and 101111

1 1 0 1 0 1
1 0 1 1 1 1
1 1 0 0 1 0 0
Binary Addition

Example:

Add 10110 and 1101

1 0 1 1 0
0 1 1 0 1
1 0 0 0 1 1
MINGGU DEPAN UTS
OFF LINE
KERTAS ESSAY
INDIVIDU
MATERI DARI PERTEMUAN 1 HINGGA
PERTEMUAN 8

You might also like