0% found this document useful (0 votes)
12 views7 pages

Chapter 4

Chapter Four discusses data representation in computers, emphasizing the binary number system as the fundamental method for storing and processing information. It covers various number systems, including decimal, binary, octal, and hexadecimal, as well as conversion methods between these systems. Additionally, it explains units of data representation, coding methods like ASCII and BCD, and techniques for representing negative numbers.

Uploaded by

yalewastatikie3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

Chapter 4

Chapter Four discusses data representation in computers, emphasizing the binary number system as the fundamental method for storing and processing information. It covers various number systems, including decimal, binary, octal, and hexadecimal, as well as conversion methods between these systems. Additionally, it explains units of data representation, coding methods like ASCII and BCD, and techniques for representing negative numbers.

Uploaded by

yalewastatikie3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

MTUCh-IV

Chapter Four
Data Representation in Computers
Objectives:
 To understand how data represented, flow, stored and processed inside the computer.
 To understand different number systems.
 To understand how to convert from one base to another and apply arithmetic operators on binary
number system.

We enter data into a computer or review (see) output data from a computer using the letter of alphabet, various
special symbols, and the numerals in the decimal number system. But since computer is an electronic device
which understands electrical flow (signal) there is no letter, symbol or number inside the computer. Computer
works with binary numbers. As a semiconductor is conducting or isn’t conducting; a switch is closed or opened. It
is not surprising, therefore, that almost all of the present day computers are based on binary system of
representation that uses only two symbols – 1 and 0.
Any information stored in the computer system is first converted into binary number and then stored in the
computer memory or hard disk in the form of 1s and 0s.

For example, to convert 7 into binary number, we divide it by 2.

Number Remainder
7/2
2 7

2 3 1

1 1

It gives a result of (111)2

Units of data representation

When data is stored, processed or communicated within the computer system, it is packed in units;
Arranged from the smallest to the largest, the units are called bit, byte and word;
BIT
 Bits are the smallest units and can convey only two possible states 0 or 1; bit stands for binary digits;
 A bit is a single element in the computer, on a disk that stands for either “ON” indicating 1 or “OFF”
indicating 0;
 In the computer “ON” is represented by the existence of current and “OFF” is represented by the non-
existence of current.
 On a magnetic disk, the same information is stored by changing the polarity or magnetized particles on
the disk’s surface.
BYTE
 Bits can be organized into large units to make them represent more and meaningful information. This
large unit is called a byte and is the basic “unit of data representation” in a computer system.

Introduction to computer Page 1


MTUCh-IV

 The commonly used byte contains 8 bits. Since each bit has two states and there are 8 bits in a byte, the
total amount of data that can be represented is 28 or 256 possible combinations.
Each byte can represent a character (a character could be either a letter, a number or a special symbol such as
+,-,?,*, $, etc.
A byte is then used as a unit of measurement in the computer memory, processing unit, external storage and
during communication.
e.g. If the computer memory is 524288 byte, this is expressed in short by saying 512KB, where KB stands for
kilobyte.
 1 Byte is 8 bites
 1 Kilobyte (1KB) is 210 or 1024 bytes
 1 Megabyte (MB) is 220 bytes or 210 kilobytes= 1024KB.
 1 Gigabyte (GB) is 230 bytes or 220 kilobytes or 210 megabytes =1024MB.
WORD
 Word refers the number of bits that a computer process at a time or a transmission media transmits at a
time. Although bytes can store or transmit information, the process can even be faster if more than one
byte is processed at a once; A combination of bytes, then form a “word”.
 A word can contain one, two, three or four bytes based on the capacity of the computer. Word length is
usually given in bits
 We say that a computer is an 8-bit, a 16 bit, a 32 bit or a 64 bit computer to indicate that the amount of
data it can process at a time.
 The large the word length a computer has the more powerful and faster it is.

Coding Methods
It is possible to represent any of the character in our language in a way as a series of electrical switches in
arranged manner.
These switch arrangements can therefore be coded as a series of an equivalent arrangements of bits.
 There are different coding systems that convert one or more character sets into computer codes, some are:
-BCD (Binary Coded Decimal), ASCII (American Standard Code for Information Interchange),and
Unicode are the most popular text coding systems invented.

BCD – Binary Coded Decimal


 The BCD used a group of four bits to represent information in the computer system. It had a maximum of
16 different alternative characters or numbers. It could represent only numbers and some special symbols.
 With BCD, each digit of a number is converted into its binary equivalent rather than converting the entire
decimal number to its binary form.
Example: The BCD value of the decimal number 5319 is 0101 0011 0001 1001
Number systems
There are different number systems. Some of are:
 Decimal number systems
 Binary number systems
 Octal number systems
 Hexadecimal number systems
Decimal number systems (base 10)
 It is the common and widely used number system. It uses 10 symbols to represent or count things, probably
it was invented because we have 10 fingers with which we count and add.
 The Decimal number system is based on the ten different digits (or symbols) 0,1,2,3,4,5,6,7,8,9.
For numbers greater than 9 it uses the symbols 0-9 to represent the number example 10, which is a combination
of 1 and 0 and so on.

Introduction to computer Page 2


MTUCh-IV

Though it is widely used, it is inconvenient for computer to represent data. So we need another number system.
Binary number system (base 2)
 Binary number system is based on the two different digits; 0 and 1. It is important to note that every
decimal number system has its equivalent binary number.
 Conversion from binary to its equivalent decimal and from decimal to its equivalent binary is possible;
Operation on bina4ry number system is also possible.
 The most elementary form to organize data within a computer (an electronic device) is in the form of a
code which utilizes the “ON” and “OFF” states of electric switches or there is “current” and “no current”
condition of the electronic components.
 We see that the nature of the electronic devices has similarity with the binary number system in that both
represent only two elementary states.

 It is therefore convenient to use binary number system to represent data in a computer. An “ON”
corresponds to a 1; an “OFF” corresponds to a 0.
 In the computer “ON” is represented by the existence of a current and “OFF” is represented by non-
existence of current
On a magnetic disk, the same information is stored by changing the polarity of magnetized particles on the disk’s
surface
Octal number System (base 8) (Oct)
 Again what would happened if we had only 8 fingers off course we would have used the 8 symbols (0-7)
and for numbers greater than we would represented them in terms of the first 8 symbols example for 8,10
and so on.It uses 8 symbols 0-7 to represent numbers
 When we compare the octal with the decimal 0-7 in octal is the same as 0-7 in decimal but 10 in octal is
not the same as 10 in decimal because 10 in octal holds the position of 8 in decimal, off course 10 in octal
is the same as 8 in decimal.
Hexadecimal number system (16) (hex)
 Suppose we had 16 fingers instead of 10 in case of 10 fingers they invented new symbols until they
exhausted all their fingers. Now they would have to invent new symbols because there would have been
some more fingers left unrepresented. These extra symbols are usually represented by the letters at the
beginning of the English alphabet.
 It uses 16 symbols to represent numbers. But for the numbers greater than 15 they represented in terms
of the 16 symbols example 16 as 10 and so on.
 When we compare the hexadecimal with decimal 0-9 in hexadecimal is the same as 0-9 in decimal but 10
in hexadecimal is not the same as 10 in decimal, off course 10 in hexadecimal is equal to 16 in decimal
because it holds the position of 16 in decimal.
Conversion from one Base to Another
The values that members have within given number systems are largely determined by their positional notation.
Positional notation means that the position of one symbol relative to other symbols in a given number system
determines the value of that symbol. For example, these symbols 1 & 7 can represent either 17 or 71 depending
upon their relative position to one another.
The decimal number 135 may be expanded as:
(135) 10 = 1*102+3*101+5*100
 The subscript 10 is used to indicate that 135 is a base 10 number. The number 10 in binary is not the same
as 10 in decimal because the value of 1 in the binary is not the same as the value of the 1 in the decimal.
The binary number 1101 can be expanded as
11012 = 1*23+1*22+0*21+1*20

Introduction to computer Page 3


MTUCh-IV

= (1*8)+(1*4) + (0*2) + (1*1)


= 8+4+0+1
= 1310
 A number X1 X2 X3 …Xn in base M can be expanded as
 (X1 X2X3 ...Xn)M=X1*Mn-1 +X2*Mn-2 + X3*Mn-3+ …Xn-1*M1+Xn*M0

Conversion from decimal to other base (Base 10 Base M)


 To convert a decimal number X to a number in base M, divide X by M, find the remainder, again divide
the result by M, find the remainder, continue until the result is 0. Finallyconcatenate (collect) the
remainders starting from the last up to the first.

Ex.1 Convert 5610 to base 2 (binary)


X=56, M=2
5610 =1110002

EX.2 Convert 7810 to base 8 (Octal)


7810=1168

EX. 3 Convert 3010 to base 16 (hexadecimal)


3010=1E16
EX. 4 Convert (160)10 to base 16 (hexadecimal)
16010=A016
Conversion from base M to base 10 (decimal)
 To convert a number X consists of digits X1 X2 X3 …Xn in base M to decimal; simply expand the number
with base M. That is
(X1X2X3…Xn) m =X1*mn-1+X2*mn-2 +X3*mn-3+ …. + XI*mn-i+… Xn-1*m1+Xn*m0 = Y10
Examples:
 Convert (1001001)2 to decimal =73
 Convert (234)8 to decimal =156
 Convert (101)8 to decimal =65
 Convert (A1B) 16 to decimal = 2587
 Convert (101)16 to decimal =257
Conversion from binary (base2) to Octal (base 8) or Hexadecimal (base16) and vice versa
 To convert a number in binary to octal ,group three binary digits together starting from the last digit (right
and if there are no enough digits add zeros in front , (left) and find the corresponding Octal of each group.
Example: Convert 1001001 to octal
1001001=001,001,001
= 1118
Convert 101101001 to octal
101101001=101,101,001
=5518
 To convert binary to hexadecimal group four binary digits together starting from right and if there are no
enough digits add zeros at the left.
Example: Convert 111100100 to hexadecimal
111100100=0001, 1110, 0100

Introduction to computer Page 4


MTUCh-IV

=1 14 4
= 1E416
 To convert from Octal to binary, convert each octal digit to its equivalent 3 bit binary starting from right.
Example: Convert (675)8 to binary
6758 =110, 111, 101
=1101111012
Convert 2318 to binary
2318 = 010, 011, 001
=100110012
 To convert from Hexadecimal to binary convert each hex digit to its equivalent 4-bit binary, starting from
right.
Example: Convert 23416 to binary
23416 =0010, 0011, 0100
= 10001101002
Convert 2AC to binary
2AC16 =0010, 1010, 1100
=10101011002
Conversion from Octal to hexadecimal and vice versa
 To convert from Octal to hexadecimal, first we have to convert to binary and the binary to hexadecimal.
To convert from hexadecimal to Octal, first we have to convert to binary and then the binary to Octal.
EX.1. Convert 2358 to hexadecimal
2358=010, 011, 101
=010011101
=0000, 1001, 1101
=0 9 13
=9D16

Convert 1A to Octal
1A=0001, 1010
=00011010
=000, 011, 010
=0 3 2
=328

Converting decimal number to BCD equivalence


 To convert a decimal number to its equivalent BCD simply convert each decimal digit to its 4bit binary
and combine the groups together
Example: Convert 432 to BCD
432=0100 0011 0010
=10000110010BCD
 To convert BCD to decimal group into four & find its corresponding decimal.

The ASCII System


 Also referred as ASCII-8 or Extended ASCII.
 It is the most widely used type of coding scheme for Micro Computer system
 ASCII uses 8-bits to represent alphanumeric characters (letters, digits and special
symbols).
 With the 8-bits, ASCII can represent 28 or 256 different characters (00000000-
11111111).
Introduction to computer Page 5
MTUCh-IV

Coding Examples:
Character zone (4 bits) digit (4 bits)
0-9 3 0-9
A-O 4 1-15
P-Z 5 0-10
a-o 6 1-15
p-z 7 0-10
a 0110 0001
b 0110 0010
A 0100 0001
B 0100 0010
? 0011 1111
+ 0010 1011
1 0011 0001

Representation of Negative numbers


 There are three ways of representing negative numbers in a computer
 Using Sign Bit
 One’s Complement
 Two’s Complement
1. Sign- magnitude representation
 In signed binary representation, the left-most bit is used to indicate the sign of the number. Traditionally,
0 is used to denote a positive number and 1 is used to denote a negative number. But the magnitude part
will be the same for the negative and positive values.
For example 11111111 represents-127 while 01111111 represents + 127
We can now represent positive and negative numbers, but we have reduced the maximum magnitude of these
numbers to 127.
In a 5- bit representation, we use the first bit for sign and the remaining 4- bits for the magnitude. So using this 5
bit representation the range of numbers that can be represented is from -15 (01111) to 15(11111)
Ex1: Represent-12 using 5-bit sign magnitude representation.
Solution: First, we convert 12 to binary i. e 1100
Now -12 = 11100
Ex2: Represent –24 using 8-bits
24=00011000
-24 = 10011000
Note: In sign magnitude representation zero can be represented as 0 or -0
2. One’s complement
 In one’s complement representation, all positive integers are represented in their correct binary format.
For example +3 are represented as usual by 00000011. However, its complement, -3, is obtained by

Introduction to computer Page 6


MTUCh-IV

complementing every bit in the original representation. Each 0 is transformed into a1 and each 1 into a0.
In our example, the one’s complement representation of -3 is 11111111.
Ex: +2 is 00000010
-2 is 11111101
3. Two’s Complement Representation
 In two’s complement representation, positive numbers are represented, as usual, in singed binary, just like
in one’s complement. The difference lies in the representation of negative numbers. A negative number
represented in two’s complement is obtained by first computing the one’s complement and then adding
one.
Ex: +3 is represented in signed binary as 00000011
Its one’s complement representation is 11111100.

Reading assignment
 Convert the following fraction numbers to each base
 A,(123.75)10 to base 2, 8, 16
 B, (abcd.25) to base 2, 8, 10
 C (67.24)8 to bae 2 , 10, 16
 D, (10101011011.10101101)2 to base 8, 10, 16

Introduction to computer Page 7

You might also like