0% found this document useful (0 votes)
9 views

ch-3

Accounting

Uploaded by

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

ch-3

Accounting

Uploaded by

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

Compiled by Berihun G. Chapter Three 2017 E.C.

Chapter Three
Data representation in computer system
Chapter objectives:
☺ To understand how really data represented, flow, stored and processed inside
the computer.
☺ To know the different coding systems & unit of data representation.

3.1 Data representation method and computer arithmetic


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. So, data are represented in the form of a code which can have a corresponding
electrical signal.

3.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. These units are based on the binary number system;

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;

Page 1
Compiled by Berihun G. Chapter Three 2017 E.C.

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;
➢ 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 is 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;
➢ If the computer memory is 524288 bytes, this is expressed in short by saying 512KB,
where KB stands for kilobyte.
✓ 1 Kilobyte(1KB) is 210 or 1024 bytes
✓ 1 Megabyte (MB) is 220 bytes or 210 kilobytes
✓ 1 Gigabyte (GB) is 230 bytes or 220 kilobytes or 210megabytes

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-bits, 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.

Page 2
Compiled by Berihun G. Chapter Three 2017 E.C.

3.3 Number System


❖ A number system is a set of symbols used for counting
❖ There are various number systems.
Ex. Decimal, Binary, octal-decimal, hexadecimal etc.
✓ The Decimal Number System
✓ The Decimal number system is based on the ten different digits (or symbols)
0,1,2,3,4,5,6,7,8,9. We say it is a base ten number system, though it is widely
used, it is inconvenient for computer to represent data.
✓ It is important because it is universally used to represent quantities outside a
digital system. Decimal system uses numbers from 0 to 9. This is to the base 10.
✓ The Binary number system
✓ 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 binary number system is also possible.
Binary/ Decimal
0 0
1 1
10 2
11 3
100 4
101 5
110 6
111 7
1000 8
1001 9 etc.

Page 3
Compiled by Berihun G. Chapter Three 2017 E.C.

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;
✓ Octal number System (base 8) (Oct)
➢ It uses 8 symbols 0-7 to represent numbers;
➢ Like binary number system it is complete number system.
Ex. 77 in octal equals to 63 in decimal and 111111 in binary.

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)


➢ It uses 16 symbols to represent numbers. But for the numbers greater than 15 they
represented in terms of the 16 symbols. For example, the decimal number 16
represented as 10, 20 as 14, 30 as 1E and so on. These symbols are 0, 1…9, A, B,
C, D, E, F (where, A=10, B=11, C=12, D=13, E=14, F=15)
➢ 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.
Example 1
DECIMAL OCTAL BINARY HEXADECIMAL
0 0 0 0
3 3 11 3
8 10 1000 8
10 12 1010 A
16 20 10000 10
Page 4
Compiled by Berihun G. Chapter Three 2017 E.C.

Example 2
Decimal Binary Code Octal Hexadecimal
0 0000 0 0
1 0001 1 1
2 0010 2 2
3 0011 3 3
4 0100 4 4
5 0101 5 5
6 0110 6 6
7 0111 7 7
8 1000 8
9 1001 9
10 1010 A
11 1011 B
12 1100 C
13 1101 D
14 1110 E
15 1111 F

3.4 Computer Arithmetic


There are different number systems. Some of are:

➢ Decimal number systems ➢ Octal number systems


➢ Binary number systems ➢ Hexadecimal number systems

We have seen the binary and decimal number system in the previous topics so we will
discuss the next two in the following topics

3.5 Conversion from one Base to Another


The values that numbers have with a given number of 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, the 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
Page 5
Compiled by Berihun G. Chapter Three 2017 E.C.

➢ The subscript 10 is used to indicate 135 is in base 10 number system.


➢ 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 may be expanded as
(1101)2 =1*23+1*22+0*21+1*20 = 8+4+0+1

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

*A number X1 X2 X3 …Xn in base M can be expanded as

(X0 X1 X2 X3 …. Xn) M=X0*mn-1+X1*mn-2X2*mn-3+ …Xd-1*m1+Xnm0 in base 10

Conversion from decimal (base 10) to another base (base M)

(Base 10……. Base M)


To convert a decimal number X to a number in base m, divide X by m, store the
remainder, again divide the quotient by M, store the remainder, and continue until the
quotient is 0. And concatenate (collect) the remainders starting from the last up to the
first.

Ex.1. Convert 5610 to base two (binary) EX.3. Convert 3010 to base sixteen
X=56 M=2 (hexadecimal)

5610 =1110002 3010=1E16

EX.2 Convert 7810 to base eight (Octal) Convert 1610 to base sixteen
7810=1168 (hexadecimal)

1610=A016

Page 6
Compiled by Berihun G. Chapter Three 2017 E.C.

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-1m1+Xn*m0

=Y10

Example1. Convert (1001001)2 to 3. Convert (101)8 to decimal


decimal
=65
=73
4. Convert (A1B) 16 to decimal
2. Convert (234)8 to decimal
= 2587
=156
5. Convert (101)16 to decimal

=257

Conversion from binary (base2) to Octal (base 8) or hexadecimal (base16) and vice
versa

Conversion from Binary to Octal:


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 to the front end
(left) and find the corresponding Octal of each group.

Ex.1 Convert 1001001 to octal Ex 2 Convert 101101001 to octal

1001001=001,001,001 101101001 =101,101,001

= 1118

=5518

Ex: 10011.110010=?

Page 7
Compiled by Berihun G. Chapter Three 2017 E.C.

➔ 010 011. 110 010


➔ 2 3 6 2
= 23.62

Conversion from Octal to Binary:


To convert from Octal to binary, convert each octal digit to its equivalent 3-bit binary
starting from right.

Ex.1 Convert (675) eight to binary

675eight =110111101

=110111101two

Ex 2 convert 231eight to binary

231eight = 010011001

=10011001two
Ex2: 377.77
Ex3: 37
011 111 111. 111 111
= 011 111
=011111
Conversion from Binary to Hexadecimal:
= 011111111.111111
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.

EX. 1 Convert 111100100 to Ex 2 Convert 111001111 to


hexadecimal Hexadecimal

111100100 =0001 1110 0100 111001111 =0001 1100 1111

=1 14 4 =1 12 15

=1 E 4 =1 B F

= 1E416 = (1BF) 16

Page 8
Compiled by Berihun G. Chapter Three 2017 E.C.

Conversion from Hexadecimal to Binary:


To convert from Hexadecimal to binary convert each hex. Digit to its equivalent 4-bit is
binary starting from right.

Ex1. Convert 23416 to binary

23416 =001000110100

= 10001101002

Ex 2 Convert 2AC to binary

2AC16 =001010101100

=10101011002

Ex3. 39A
=0011 1001 1010
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

2388=010 011 101

=000010011101

= 0 9 13

=9D16

Conversion from hexadecimal to Octal

Ex 2 Convert 1A to Octal

1A=0001 1010

Page 9
Compiled by Berihun G. Chapter Three 2011 E.C.

=000 011 010

=0 3 2

=328

Octal → Binary → Hexadecimal:


7521→ Octal
111 101 010 001 → Binary
1111 0101 0001→ Hexadecimal

Hexadecimal → Octal:
CBAED → Hexadecimal
C B A E D
1100 1011 1010 1110 1101
011 001 011 101 011 101 101
3 1 3 5 3 5 5
CBAED = 3135355

3.6 Binary Arithmetic


Computer understands only the language of binary numbers. Therefore, the machine performs
what is called binary arithmetic (binary computation).

3.6.1 Binary addition


Binary addition operates by the same rule as decimal addition, except that it is simpler. A carry
to the next higher order (or more significant) position occurs when the sum is decimal 2, that is,
binary 10. Therefore, the binary addition rules may be written as follows:

0+0=0
0+1=1
1+0=1
1+1=0 plus a carry of 1 into the next position
1+1+1=1 plus a carry of 1 into the next position
The last case occurs when the two binary digits in a certain position are 1s and there is a carry
from the previous position.

Example1:

Page 10
Compiled by Berihun G. Chapter Three 2011 E.C.

6+7 =13

110+111=1101

Example2

19+31+10=60

10011 +11111+1010=111100

3.6.2 Binary Subtraction


It operates by the same rule as decimal subtraction. The rule is as follows;

0-0=0

1-0=1

1-1=0

10-1=1

Example:

11100 28 101101 45

- 11010 -26 - 111 -7

00010 =2 100110 =38

3.6.3 Binary Multiplication


- It is a very simple process that operates by the following obvious rules:

(a) Multiplying any number by 1 rule the multiplicand unchanged


0x1=0

1x1=1

(b) Multiplying any number by 0 produces 0


0x0=0

1x0=0

Representation of Negative Numbers

Page 11
Compiled by Berihun G. Chapter Three 2011 E.C.

There are different ways of representing negative numbers in a computer.


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.
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 number that can be represented is from -15
(11111) to 15(01111)
In the binary number system there are two types of complements, 1’s complement and 2’s
complement. To represent a negative binary number 2’s complement is most widely used. To
understand 1’s and 2’s complement in the binary number system one should first understand 9’s
and 10’s complements in the decimal number system.

3.6.4 One’s complement


The 1’s complement of binary number is similar to 9’s complement in the decimal system. To
get 1’s complement of a binary number each bit of the binary number is subtracted from 1. The
1’s complement of 01 is 10. Thus, we can see that the 1’s complement of a binary number can be
obtained by simply changing each bit 1 to 0 and 0 to 1.
Ex: +2 is 00000010

-2 is 11111101

Note that in this representation positive numbers start with a 0 on the left, and negative numbers
start with a 1 on the left most bit.

Ex 2: Find 1’s complement of 1100101


The 1’s complement is 0011010
Ex3. Add –3 and 3 with word size 4

3 = 0011

-3=1100

Sum = 1111 (=0)

Ex2. Add -4 and +6

- 4 is 11111011

+ 6 is 00000110
Page 12
Compiled by Berihun G. Chapter Three 2011 E.C.

The sum is (1) 00000001 the one in the parenthesis is the external carry.

Where 1 indicates a carry

The correct result should be 2 or 00000010.

In one’s complement addition and subtraction, if there is an external carry it should be added to
get the correct result. This indicates it requires additional circuitry for implementing this
operation.

2’s Complement:
The 2’s complement of the binary system is similar to 10’s complement in the decimal system. Thus the
2’s complement of a binary number is equal to the 1’s complement of the number plus one.

Ex: 11010 (2) =? 2’s complement


1’s complement of 11010 is 00101
+ 1
00110
 11010 (2) = 00110 (2’s complement)

Ex2: 0000 (2) =? 2’s complement


1’s complement of 000 is 1111
1
10000
0000 => 1 0000 (here 1 is carry)

Page 13

You might also like