SlideShare a Scribd company logo
1 of 16
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 1
Data Representation
Chapter Two
 Data Representation in a computer
We have all seen computers do seemingly miraculous things with all kinds of sounds, pictures,
graphics, numbers, and text. It seems that we can build a replica of parts of our world inside the
computer. You might think that this amazing machine is also amazingly complicated. It really is
not. I fact, all constructed from simple ON/OFFswitches millions of them, but really nothing much
more complicated than a switch. The trick is to take all of the real-world sound, picture, number
etc. data that we want in the computer and converted it into the kind of data that can be represented
in switches.
Computers are electronic machines. The computer uses electricity, not mechanical parts, for its
data processing and storage. Electricity is plentiful, moves very fast through wires, and electrical
parts fail less much less frequently that mechanical parts. The computer does have some
mechanical parts, like its disk derive (which are often the source for computer failures), but the
internal data processing and storage is electronic, which is fast and reliable (as long as the computer
is plugged in).
Electricity can flow through switches: if the switch is closed, the electricity flows; if the switch is
pen, the electricity does not flow. To process real-world data in the computer, we need a way to
represent the data in switches. Computer do this representation using a binary coding system.
Binary and Switches: Binary is mathematical number system: a way of counting. We have all
learned to count using ten digits:0-9. One probable reason is that we have ten fingers to represent
numbers. The computer has switches to represent data and switches have only two states: ON and
OFF. Binary has two digits to do counting: 0 and 1 a natural fit to the two states of a switch (0 =
OFF, 1 =ON).
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 2
Data Representation
Grouping bits together: widely in reference to computer memory and data size.
 Bits: can be defined as either a binary, which can be 0, or 1.It is the basic unit of data or
information in digital computers.
 Byte: a group of bits (8 bits) used to represent a character. A byte is considered as the basic
unit of measuring memory size in computer.
 A nibble: is half a byte, which is usually a grouping of 4 bytes.
 Word: two or more bits make a word. The term word length is used as the measure of the
number of bits in each word. For example, a word can have a length of 16 bits, 32 bits, 64
bits etc.
Computer designers use eight bit chunks called bytes as the basic unit of data. The byte is
implemented with eight switches.
Computer manufacturers express the capacity of memory and storage in terms of the number of
bytes it can hold. The number of bytes can be expressed as kilobytes. Kilo represents 2 to the tenth
power, or 1024. Kilobyte is abbreviated KB, or simply K. Memory of a 640K computer can store
640 * 1042, or 655,360 bytes. Memory capacity may also be expressed in MB (1024*1024), GB,
TB.
1Bit = 20 Binary Digit
8Bits = 23 1 Byte
1024Bytes = 210 1KB Kilo Byte
1024KB = 220 1MB Mega Byte
1024MB = 230 1GB Giga Byte
1024GB = 240 1GB Terra Byte
1024TB = 250 1PB Peta Byte
1024EB = 260 1EB Exa Byte
1024ZB = 270 1ZB Zerra Byte
1024YB = 280 1YB Yotta Byte
1024YB = 290 1BB Bronto Byte
1024BB = 2100 1GB Geop Byte
 Kb is not KB
As shown above picture computer represent every data in 0s and 1s. So, how this can be do, will
see one by one in following sections.
 Characters: how a computer represent characters? The characters must converted into
binary. This can be done using American Standard Code for Information Interchange
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 3
Data Representation
(ASCII). ASCII-8, common version use 8 bits per character and represent 256 different
characters. For example, the latter A is represented by 01000001.
 Picture and Graphic: photographs are a big grid of colored dots. Computer graphic data
like pictures, frames of a movie, drawings, or frames of an animation are represented by a
grid of pixels. Pixel is short for picture element. In simple graphics (those without many
colors), a byte can represent a single pixel. In a graphic representation called greyscale
each pixel is a shade of grey from black at one extreme to white at the other. Since eight
bytes can hold 256 different integers (0-255 as described a few paragraphs ago), a pixel in
one byte can be one of 256 shades of grey (usually with 0 being white and 255 being black).
Modern video games and colorful graphics use several bytes for each pixel (Nintendo 64
uses eight bytes = 64 bits for each pixel to get a huge array of possible colors). A scanned
photograph or a computer drawing is thus stored as thousands of bytes - each byte, or
collection of bytes, representing a pixel.
We saw that computer manufacturers got together and agreed how characters will be represented
(the ASCII code). For graphics, there are several similar standards or formats. Two common
picture formats used on the Internet are JPEG and GIF. These, like ASCII, are agreed-upon
common coding of pixels in bytes.
 Sound: Sound occurs naturally as an analog wave, as shown in Figure below
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 4
Data Representation
Most current electronic speakers, the means that we use to electronically reproduce sound, also
produce analog waves. However, as we have seen, all data in the computer is digital and must be
processed in bytes. The process of taking analog data, such as sound, and making it digital is called
analog to digital conversion. Many music CD's from old original analog recordings on tapes were
converted to digital to be placed on a CD (a CD is digital; it is just a collection of bits with a small
hole burned in the CD representing a 1 and no hole representing a 0). Current music CD's have the
analog to digital conversion done in the recording equipment itself, which produces better
conversion.
To convert an analog wave into digital, converters use a process called sampling. They sample the
height of the sound wave at regular intervals of time, often small fractions of a second. If one byte
is used to hold a single sample of an analog wave, then the wave can be one of 256 different heights
(0 being the lowest height and 255 being the highest). These heights represent the decibel level of
the sound. Thus a spoken word might occupy several hundred bytes - each being a sample of the
sound wave of the voice at a small fraction of a second. If these 100 bytes were sent to a computer's
speaker, the spoken word would be reproduced.
Like ASCII for characters and GIF and JPEG for pictures, sound has several agreed-upon formats
for representing samples in bytes. WAV is a common format on the Internet.
 Program: collection of instructions that someone wrote to tell the computer to perform the
task that the software is meant to do. Each instruction is a byte, or a small collection of
bytes. If a computer used one byte for an instruction, it could have up to 256 instructions.
Later we will look at what these instructions are, but for now, you should realize that a byte
could also be a computer's instruction. The conversion of instructions to bytes is shown in
Figure below.
The programming process allows humans to write instructions in an English-like way. A software
program called a compiler then transforms the English-like text into the bytes for instructions that
the computer understands.
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 5
Data Representation
Like all other kinds of data, there are agreed-upon formats for computer instructions too. One
reason that Macintosh computer programs do not run natively on PC-compatible (Intel-based)
computers, is that Macintoshes and Intel PCs use different formats for coding instructions in bytes.
 Integers: integer numbers are represented by counting in binary. In decimal we start from
0 to count and when we reach 9 the end of decimal place and we use two digits to count by
putting a digit in the “tens place” and starting over again using our 10 digits. Thus, the
decimal number 10 is a 1 in the “tens place” and a zero in the “ones place”. And if we need
three digits, like 122, we use a third digit in the “hundred’s place”.
We do a similar thing to count in binary- except now we only have two digits: 0 and 1. So we start
with 0, then 1, then we run out of digits, so we need to use two digits to keep counting. We do this
by putting a 1 in the “two’s place” and then using our two digits. Thus two is 10 binary: a 1 in the
“two’s place” and a 0 in the “one’s place”. Three is 11: a 1 in the “two’s place” and a 1 in the
“one’s place”. We run out of digits again! Thus, four is 100: a 1 in the” four’s place” a 0 in the
“two’s place” a 0 in the “one’s place”.
 How Does The Computer Know What a Byte Represents?
We have seen that the byte:
01000011
can represent the integer 67, the character 'C', a pixel with darkness level 67, a sample of a sound
with decibel level 67, or an instructions. There are other types of data that a byte can represent too.
If that same byte can be all of those different types of data, how does the computer know what
type it is? The answer is the context in which the computer uses the byte. If it sends the byte to a
speaker, the 67th level of sound is produced. If it sends the byte to a monitor or printer, a pixel
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 6
Data Representation
with the 67th level of darkness is produced, etc. More accurately, if the byte were coded with a
standard coding technique, like ASCII for characters, GIF for pictures, and WAV for sounds,
then when the computer sends the byte to a device, the data corresponding to that coding is
produced by the device.
Number system
1. Decimal : base (radix) is 10
2. Hexal : base (radix) is 16
3. Octal : base (radix) is 8
4. Binary : base (radix) is 2
They are the way of number representation. However, in computer only binary can be use
and other must converted into this binary. It has proved difficult to develop devices that
can understand natural language directly due to the complexity of natural languages.
However, it is easier to construct electric circuits based on the binary or ON and OFFlogic.
All forms of data can be represented in binary system format. Other reasons for the use of
binary are that digital devices are more reliable, small and use less energy as compared to
analog devices. This is the main reason to study binary number system.
1. Decimal number system
o The term decimal is derived from a Latin prefix deci, which means ten. Decimal number
system has ten digits ranging from 0-9. Because this system has ten digits; it is also called
a base ten number system or denary number system.
o A decimal number should always be written with a subscript 10 e.g. X10
o But since this is the most widely used number system in the world, the subscript is
usually understood and ignored in written work. However ,when many number
systems are considered together, the subscript must always be put so as to
differentiate the number systems.
o The magnitude of a number can be considered using these parameters.
o Absolute value
o Place value or positional value
o Base value
 The absolute value is the magnitude of a digit in a number. for example the
digit 5 in 7458 has an absolute value of 5 according to its value in the
number line.
 The place value of a digit in a number refers to the position of the digit in
that number i.e. whether; tens, hundreds, thousands etc.
 The total value of a number is the sum of the place value of each digit
making the number.
 The base value of a number also k known as the radix, depends on the type
of the number systems that is being used .The value of any number depends
on the radix. for example the number 10010 is not equivalent to 1002.
2. Binary number system
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 7
Data Representation
It uses two digits namely, 1 and 0 to represent numbers. unlike in decimal numbers where the place
value goes up in factors of ten, in binary system, the place values increase by the factor of 2.binary
numbers are written as X2.consider a binary number such as 10112.The right most digit has a place
value of 1×20 while the left most has a place value of 1×23.
3. Octal number system
Consists of eight digits ranging from 0-7.the place value of octal numbers goes up in factors of
eight from right to left.
4. Hexadecimal number system
This is a base 16 number system that consists of sixteen digits ranging from 0-9 and letters A-F
where A is equivalent to 10,B to 11 up to F which is equivalent to 15 in base ten system. The place
value of hexadecimal numbers goes up in factors of sixteen. A hexadecimal number can be denoted
using 16 as a subscript or capital letter H to the right of the number .For example, 94B can be
written as 94B16 or 94BH.
Hexadecimal Decimal Octal Binary
00 00 0 0000
01 01 1 0001
02 02 2 0010
03 03 3 0011
04 04 4 0100
05 05 5 0101
06 06 6 0110
07 07 7 0111
08 08 1000
09 09 1001
A 10 1010
B 11 1011
C 12 1100
D 13 1101
E 14 1110
F 15 1111
 Converting binary numbers to decimal numbers
 To convert a binary number to a decimal number, we proceed as follows:
 First, write the place values starting from the right hand side.
 Write each digit under its place value.
 Multiply each digit by its corresponding place value.
 Add up the products. The answer will be the decimal number in base ten.
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 8
Data Representation
 EXAMPLE
 Convert 1011012 to base 10(or decimal) number
Place value 2524 232221 20
Binary digits 1 0 1 1 0 1
 Multiply each digit by its place value
N10=(1*25) +(0*24)+(1*23)+(1*22)+(0*21)+(1*20)
N10=32+0+8+4+0+1
=4510
 32*1=32
 16*0=0
 8*1=8 4*1=4
 2*0=0
 1*1=1
 =4510
 NB: remember to indicate the base subscript since it is the value that distinguishes the
different systems.
 Example
 Convert 11.0112 to a decimal number.
 Solution
 Convert the integral and the fractional parts separately then add them up.
 2×1= 2.000
 1×1= +1.000
 3.00010
Weight 21 20.2-12-2 2-3
Binary digit 1 1 .0 1 1
Values in base 102 1 .0 0.250.125
 0.50×0 =0.000
 0.25×1 =0.250
 0.125×1=+0.125
 0.37510
 3.00010+0.37510= 3.37510
 Thus 11.0112=3.37510
 ) Converting a decimal to binary
 Divide the integral part continuously by 2 till 1
 Group the reminder from last to initial or first. This will give the binary equivalent.
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 9
Data Representation
 Example convert 39 to binary
 And if the decimal number has fraction part multiply by 2 till fractional subsequent product
is 0 or starts to repeat itself.
 And grouping the carry (left of the decimal point) from first (beginning) to last
(end).
 Example : convert 0.625 to binary
 0.625 x 2 = 1.25  0.25 with a carry of 1
 0.25 x 2 = 0.50  0.50 with a carry of 0
 0.50 x 2 = 1.00  0.00 with a carry of 1
 0.625 = 0.101
 If the decimal is like 39.625 and need to convert binary. This can be done by
separating before the decimal and after the decimal then combine. 100111.101
 Converting octal to binary
 Working from left to the right, each octal number is represented using three digits
and then combined; we get the final binary equivalent.
 Example convert 3218 to binary equivalent
 3 = 011
 2 = 010
 1 = 001
 Combining the three from left to right 011010001
 Converting binary to octal
 grouping the binary number by three digits starting from right to left and take its
decimal equivalent
 Example convert 011010001 to octal equivalent
 011 = 3
 010 = 2
 001 = 1
 Then 3218 is the equivalent octal.
 Converting hexadecimal to binary
 Working from left to the right, each hexa number is represented using four digits
and then combined; we get the final binary equivalent.
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 10
Data Representation
 Example convert D1 to binary equivalent
 D = 1101
 1 = 0001
 Combining the two from left to right 11010001
 Converting binary to hexadecimal
 Grouping the binary number by four digits from right to left and take its decimal
equivalent
 Example convert 11010001 to hexadecimal equivalent
 1101 = D
 0001 = 1
 Then D116 is the hexa equivalent
 Converting octal to decimal
 The same steps binary to decimal conversion except radix difference
 Example convert 5128 to decimal equivalent
Place value 82 81 80
648 1
Octal digit 5 1 2
 Write each number under its place value as shown below
 Multiply each number by its place value.
 Converting hexadecimal numbers to decimal number
To convert hexadecimal number to base 10 equivalent we proceed as follows:
First, write the place values starting from the right hand side.
1. If a digit is a letter such as ‘A’ write its decimal equivalent
 Multiply each hexadecimal digit with its corresponding place value and then add the
products
N10=(5 x 82)+(1 x 81 )+(2 x 80 )
=(5 x 64)+8+2
=320+8+2
N10=33010
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 11
Data Representation
 The following examples illustrate how to convert hexadecimal number to a decimal
number
Example
Convert the hexadecimal number 11116 to its binary equivalent
Solution
Place each number under its place value.
162161 160
1 1 1
256 x1= 256
16 x 1 = 16
1 x 1= + 1
273
Therefore 11116 =27310
 Binary arithmetic operations
 In mathematics, the four basic arithmetic operations applied on numbers are
addition, subtracstion, multiplications and division.
 In computers, the same operations are performed inside the central processing unit
by the arithmetic and logic unit (ALU). However, the arithmetic and logic unit
cannot perform binary subtractions directly. It performs binary subtractions using
a process known as for multiplication and division, the arithmetic and logic unit
uses a method called shifting before adding the bits.
 Representation of number as an integer:
 When an integer binary number is positive, the sign is represented by 0 and the magnitude
by a positive binary number.
 When the number is negative, the sign is represented by 1 but the rest of the number may
be represented in one of three possible ways:
1. Signed magnitude representation
2. Signed 1’s complement representation
3. Signed 2’s complement representation
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 12
Data Representation
Example: Consider the signed number 14 stored in an 8 bit register.
+14 is represented by a sign bit of 0 in the leftmost position followed by the binary equivalent of
14  00001110. Note that each of the eight bits of the register must have a value and, therefore,
0’s must be inserted in the most significant positions following the sign bit.
Although there is only one way to represent +14, there are three different ways to represent -14
with eight bits.
Sign bit
In signed magnitude representation 1 0001110
In signed 1’s complement representation 1 1110001
In signed 2’s complement representation 1 1110010
The signed magnitude representation of -14 is obtained from +14 by complementing only the
sign bit.
The signed 1’s complement representation of -14 is obtained by complementing all the bits of
+14, including the sign bit.
The signed 2’s complement representation is obtained by taking the 2’s complement of the
positive number, including its sign bit.
1. Signed magnitude representation
In this representation if we have n digits the absolute value is 2n-1and 1 digit for sign 0 for positive
or 1 for negative. And zero has two representation both positive and negative. This ambiguity
make its method slow. For example if you have 4 bits representation in signed magnitude as
follows:
0 0000 1000 -0
1 0001 1001 -1
2 0010 1010 -2
3 0011 1011 -3
4 0100 1100 -4
5 0101 1101 -5
6 0110 1110 -6
7 0111 1111 -7
 Performing arithmetic from this representation is difficult and dependent on the sign bit
which is the left most bit if it is 0 the number is positive and if it is 1 the number is negative.
 Because of these ambiguity and complexity it is not use todays.
 Example : 1-6
 1 == 0001
 -6== 1110
 Sum==1111-7 but the result must be -5 this is why this method is complex. However, if
the numbers are both positive no problem can add simply.
 Example 5 +6
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 13
Data Representation
 5 === 0101
 6 ===0110
 Sum =1011
2. Signed 1’s complement representation
 This method can minimize the drawback of signed magnitude problems. Even though it
has its own drawback that is delay of operation.
 1’s complement of the number can be obtained by changing the bit that is 1 into 0, 0 into
1 or subtract all bits from all 1’s.
 Example 1’s complement of 0 in four bits is 1111. How?
 0 in four bits is = 0000
 The change 0 into 1 = 1111
 Or subtract from all 1’s
 1111
-
0000
1111 which is the same result.
0 0000 1000 -7
1 0001 1001 -6
2 0010 1010 -5
3 0011 1011 -4
4 0100 1100 -3
5 0101 1101 -2
6 0110 1110 -1
7 0111 1111 -0
 Example 6-2 which is equal to 6+(-2)
 6 == 0110
 -2 == 1101
 Result =10011. There is carry bit and it has to be add from right side.
 Therefore 0011 +1 is 0100 the correct answer.
 These adding of carry bit causes delay and decrease the performance. So we need
other method better than this that is 2’s complement.
3. Signed 2’s complement representation
 This representation can solve the drawback of the two method those described above.
 The first bit absolute value is negative such as -0000  -1 * 23+ 0*22+0 * 21+ 0*20 = -8
like this the following four bits example has given for further examples in 2’s complement.
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 14
Data Representation
-23222120 -23222120
0 0000 1000 -8
1 0001 1001 -7
2 0010 1010 -6
3 0011 1011 -5
4 0100 1100 -4
5 0101 1101 -3
6 0110 1110 -2
7 0111 1111 -1
 Example 6-2 which is 6+(-2)
 6 = 0110
 -2 = 1110, that is different in signed magnitude, 1’s complement and here and the best
method is this one.
 Therefore 6 + (-2) is 10100 there is carry and you have to discard it rather than adding
again like in 1’s compliment operation.
 So addition and subtraction can done like these. The expression is like X – Y = X + (-Y) .
Note: Generally Complement is r complement and r-1 complement. The r complement such as
10 for decimal or 2 for binary number system and r-1 complement such as 9 complement for
decimal and 1 complement for binary number systems.
 9’complement:
To form the 9’s complement of decimal number each digit of a decimal number is subtracted from
9. The result so obtained is known as 9’s complement of the number.
Ex: Find 9’s complement of decimal number 37(10)
Sol : 37(10) = 9’s complement ?
9’s complement of 37 is 99 – 37 = 62.
Like that…3977(10) = 9’s complement ?
9’s complement of 3977 is 9999 – 3977 = 6022.
 10’s complement:
The 10’s complement of a decimal number is equal to the 9’s complement of the number plus 1.
10’s complement of 37 is 99 – 37 = 62 +1 = 63.
Overflow:
When two numbers of n digits each are added and the sum occupies n+1 digits, we say that
an overflow occurred.
An overflow is a problem in digital computers because the width of registers is finite.
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 15
Data Representation
A result that contains n+1 bits cannot be accommodated in a register with a standard length
of n bits. For this reason, many computers detect the occurrence of an overflow, and when it occurs,
a corresponding flip-flop is set which can then be checked by the user.
 An overflow may occur if the two numbers added are both positive and both
negative.
Example: Two signed binary numbers, +70 and +80, are stored in two 8bit registers.
carries : 0 1 carries: 1 0
+70 0 1000110 -70 1 0111010
+80 0 1010000 -80 1 0110000
+150 1 0010110 -150 0 1101010
Note that the 8 bit result that should have been positive has a negative sign bit and the 8bit result
that should have been negative has a positive sign bit. If, however, the carry out of the sign bit
position is taken as the sign bit of the result, the 9 bit answer so obtained will be correct.
Since the answer cannot be accommodated within 8 bits, we say that an overflow occurred. If the
two carries are applied to an exclusive-OR gate, an overflow will be detected when the output of
the gate is equal to 1.
 Floating-Point Representation
In this representation decimal numbers are represented with a fixed length format. In order not to
waste bits, the representation will normalize all the numbers. For example, 0.000123 wastes three
zeroes on the left before non -zero digits. These zeroes have no meaning except to indicate the
position of the Decimal point. Normalizing this number result in .123x10-3 .123 is the normalized
mantissa; -3 is the exponent. We have normalized this by eliminating all the meaningless zeroes
to the left of the first non-zero digit and by adjusting the exponent.
Ex1: 22.1 is normalized as .221x102.
The general form of floating point representation is Mx10E where M is the mantissa, and E is
the exponent. It can be seen that a normalized number is characterized by a mantissa less than 1
and greater than or equal to.1 all cases when the number is not zero.
To represent floating numbers in the computer system it should be normalized after converting to
binary number representation system.
Samara University
College of Engineering and Technology
Department of Information Technology
====================================================================================
GIRMACHEW 16
Data Representation
Ex2 111.01 is normalized as .11101x23.
The mantissa is 11101. The exponent is 3.
The general structure of floating point is
Sign Exponent Mantissa (significand)
In representing a number in floating point we use 1 bit for sing, some bits for exponent and the
remaining bit for mantissa.
 Fixed Point Representation
Positive Integers, including zero, can be represented as unsigned numbers. However, to represent
negative integers, we need a notation for negative values. In ordinary arithmetic, a negative number
is indicated by a minus sign and a positive number by a plus sign.
Because of hardware limitations, computers must represent everything with 1’s and 0’s, including
the sign of a number. As a consequence, it is customary to represent the sign with a bit placed in
the leftmost position of the number.
There are two ways of specifying the position of the binary point in a register by giving it a works
using fixed position or by employing a floating point representation. The fixed point method
assumes that the binary pint is always fixed in one position. The two positions most widely used
are
1) A binary point in the extreme left of the register to make the stored number a fraction,
and
2) A binary point in the extreme right of the register to make the stored number an integer.

More Related Content

What's hot

Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
Mariana Soffer
 

What's hot (20)

Binary addition.pptx
Binary addition.pptxBinary addition.pptx
Binary addition.pptx
 
Number system
Number systemNumber system
Number system
 
Computer Science & Information Systems
Computer Science & Information SystemsComputer Science & Information Systems
Computer Science & Information Systems
 
Binary number system
Binary number systemBinary number system
Binary number system
 
Von Neumann Architecture
Von Neumann ArchitectureVon Neumann Architecture
Von Neumann Architecture
 
Data Representation
Data RepresentationData Representation
Data Representation
 
Number System in CoMpUtEr
Number System in CoMpUtErNumber System in CoMpUtEr
Number System in CoMpUtEr
 
Introduction to computer Powerpoint Presentation
Introduction to computer Powerpoint PresentationIntroduction to computer Powerpoint Presentation
Introduction to computer Powerpoint Presentation
 
Natural Language Processing
Natural Language ProcessingNatural Language Processing
Natural Language Processing
 
Binary number ppt
Binary number pptBinary number ppt
Binary number ppt
 
Software
SoftwareSoftware
Software
 
Programming language
Programming languageProgramming language
Programming language
 
Loops in Python
Loops in PythonLoops in Python
Loops in Python
 
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
Python Tutorial For Beginners | Python Crash Course - Python Programming Lang...
 
Information retrieval 10 tf idf and bag of words
Information retrieval 10 tf idf and bag of wordsInformation retrieval 10 tf idf and bag of words
Information retrieval 10 tf idf and bag of words
 
11 Unit1 Chapter 1 Getting Started With Python
11   Unit1 Chapter 1 Getting Started With Python11   Unit1 Chapter 1 Getting Started With Python
11 Unit1 Chapter 1 Getting Started With Python
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Machine language
Machine languageMachine language
Machine language
 
NUMBER SYSTEM
NUMBER SYSTEMNUMBER SYSTEM
NUMBER SYSTEM
 
Introduction to programming languages
Introduction to programming languagesIntroduction to programming languages
Introduction to programming languages
 

Similar to Data representation in a computer

Chapter 2Hardware2.1 The System Unit2.2 Data and P
Chapter 2Hardware2.1 The System Unit2.2 Data and PChapter 2Hardware2.1 The System Unit2.2 Data and P
Chapter 2Hardware2.1 The System Unit2.2 Data and P
EstelaJeffery653
 
Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems Ppt
ekul
 
Learning& Teaching Systems Ppt
Learning& Teaching  Systems PptLearning& Teaching  Systems Ppt
Learning& Teaching Systems Ppt
Naruin
 
Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems Ppt
Kyle
 
Introduction to programming concepts
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming concepts
hermiraguilar
 
Introduction to programming concepts
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming concepts
hermiraguilar
 

Similar to Data representation in a computer (20)

Data representation
Data representationData representation
Data representation
 
ICT - Lecture Notes 4.pdf
ICT - Lecture Notes 4.pdfICT - Lecture Notes 4.pdf
ICT - Lecture Notes 4.pdf
 
Chapter 2Hardware2.1 The System Unit2.2 Data and P
Chapter 2Hardware2.1 The System Unit2.2 Data and PChapter 2Hardware2.1 The System Unit2.2 Data and P
Chapter 2Hardware2.1 The System Unit2.2 Data and P
 
Computer Systems
Computer SystemsComputer Systems
Computer Systems
 
New Computer Systems
New Computer SystemsNew Computer Systems
New Computer Systems
 
Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems Ppt
 
Learning& Teaching Systems Ppt
Learning& Teaching  Systems PptLearning& Teaching  Systems Ppt
Learning& Teaching Systems Ppt
 
Learning&Teaching Systems Ppt
Learning&Teaching Systems PptLearning&Teaching Systems Ppt
Learning&Teaching Systems Ppt
 
1.1.1 binary systems By Zak
1.1.1 binary systems By Zak1.1.1 binary systems By Zak
1.1.1 binary systems By Zak
 
Computer repair -_a_complete_illustrated_guide_to_pc_hardware
Computer repair -_a_complete_illustrated_guide_to_pc_hardwareComputer repair -_a_complete_illustrated_guide_to_pc_hardware
Computer repair -_a_complete_illustrated_guide_to_pc_hardware
 
Computer illustrated guide to the pc hardware
Computer illustrated guide to the pc hardwareComputer illustrated guide to the pc hardware
Computer illustrated guide to the pc hardware
 
Computer data representation (integers, floating-point numbers, text, images,...
Computer data representation (integers, floating-point numbers, text, images,...Computer data representation (integers, floating-point numbers, text, images,...
Computer data representation (integers, floating-point numbers, text, images,...
 
UNIT-I U20EST109 - PROBLEM SOLVING APPROACH - Copy (1).pptx
UNIT-I U20EST109 - PROBLEM SOLVING APPROACH - Copy (1).pptxUNIT-I U20EST109 - PROBLEM SOLVING APPROACH - Copy (1).pptx
UNIT-I U20EST109 - PROBLEM SOLVING APPROACH - Copy (1).pptx
 
Number system
Number system Number system
Number system
 
CST-20363-Session 1-In the Bitginning
CST-20363-Session 1-In the BitginningCST-20363-Session 1-In the Bitginning
CST-20363-Session 1-In the Bitginning
 
Digital Technology
Digital TechnologyDigital Technology
Digital Technology
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
Introduction to programming concepts
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming concepts
 
Introduction to programming concepts
Introduction to programming conceptsIntroduction to programming concepts
Introduction to programming concepts
 
Lesson4.2 u4 l1 binary squences
Lesson4.2 u4 l1 binary squencesLesson4.2 u4 l1 binary squences
Lesson4.2 u4 l1 binary squences
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 

Data representation in a computer

  • 1. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 1 Data Representation Chapter Two  Data Representation in a computer We have all seen computers do seemingly miraculous things with all kinds of sounds, pictures, graphics, numbers, and text. It seems that we can build a replica of parts of our world inside the computer. You might think that this amazing machine is also amazingly complicated. It really is not. I fact, all constructed from simple ON/OFFswitches millions of them, but really nothing much more complicated than a switch. The trick is to take all of the real-world sound, picture, number etc. data that we want in the computer and converted it into the kind of data that can be represented in switches. Computers are electronic machines. The computer uses electricity, not mechanical parts, for its data processing and storage. Electricity is plentiful, moves very fast through wires, and electrical parts fail less much less frequently that mechanical parts. The computer does have some mechanical parts, like its disk derive (which are often the source for computer failures), but the internal data processing and storage is electronic, which is fast and reliable (as long as the computer is plugged in). Electricity can flow through switches: if the switch is closed, the electricity flows; if the switch is pen, the electricity does not flow. To process real-world data in the computer, we need a way to represent the data in switches. Computer do this representation using a binary coding system. Binary and Switches: Binary is mathematical number system: a way of counting. We have all learned to count using ten digits:0-9. One probable reason is that we have ten fingers to represent numbers. The computer has switches to represent data and switches have only two states: ON and OFF. Binary has two digits to do counting: 0 and 1 a natural fit to the two states of a switch (0 = OFF, 1 =ON).
  • 2. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 2 Data Representation Grouping bits together: widely in reference to computer memory and data size.  Bits: can be defined as either a binary, which can be 0, or 1.It is the basic unit of data or information in digital computers.  Byte: a group of bits (8 bits) used to represent a character. A byte is considered as the basic unit of measuring memory size in computer.  A nibble: is half a byte, which is usually a grouping of 4 bytes.  Word: two or more bits make a word. The term word length is used as the measure of the number of bits in each word. For example, a word can have a length of 16 bits, 32 bits, 64 bits etc. Computer designers use eight bit chunks called bytes as the basic unit of data. The byte is implemented with eight switches. Computer manufacturers express the capacity of memory and storage in terms of the number of bytes it can hold. The number of bytes can be expressed as kilobytes. Kilo represents 2 to the tenth power, or 1024. Kilobyte is abbreviated KB, or simply K. Memory of a 640K computer can store 640 * 1042, or 655,360 bytes. Memory capacity may also be expressed in MB (1024*1024), GB, TB. 1Bit = 20 Binary Digit 8Bits = 23 1 Byte 1024Bytes = 210 1KB Kilo Byte 1024KB = 220 1MB Mega Byte 1024MB = 230 1GB Giga Byte 1024GB = 240 1GB Terra Byte 1024TB = 250 1PB Peta Byte 1024EB = 260 1EB Exa Byte 1024ZB = 270 1ZB Zerra Byte 1024YB = 280 1YB Yotta Byte 1024YB = 290 1BB Bronto Byte 1024BB = 2100 1GB Geop Byte  Kb is not KB As shown above picture computer represent every data in 0s and 1s. So, how this can be do, will see one by one in following sections.  Characters: how a computer represent characters? The characters must converted into binary. This can be done using American Standard Code for Information Interchange
  • 3. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 3 Data Representation (ASCII). ASCII-8, common version use 8 bits per character and represent 256 different characters. For example, the latter A is represented by 01000001.  Picture and Graphic: photographs are a big grid of colored dots. Computer graphic data like pictures, frames of a movie, drawings, or frames of an animation are represented by a grid of pixels. Pixel is short for picture element. In simple graphics (those without many colors), a byte can represent a single pixel. In a graphic representation called greyscale each pixel is a shade of grey from black at one extreme to white at the other. Since eight bytes can hold 256 different integers (0-255 as described a few paragraphs ago), a pixel in one byte can be one of 256 shades of grey (usually with 0 being white and 255 being black). Modern video games and colorful graphics use several bytes for each pixel (Nintendo 64 uses eight bytes = 64 bits for each pixel to get a huge array of possible colors). A scanned photograph or a computer drawing is thus stored as thousands of bytes - each byte, or collection of bytes, representing a pixel. We saw that computer manufacturers got together and agreed how characters will be represented (the ASCII code). For graphics, there are several similar standards or formats. Two common picture formats used on the Internet are JPEG and GIF. These, like ASCII, are agreed-upon common coding of pixels in bytes.  Sound: Sound occurs naturally as an analog wave, as shown in Figure below
  • 4. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 4 Data Representation Most current electronic speakers, the means that we use to electronically reproduce sound, also produce analog waves. However, as we have seen, all data in the computer is digital and must be processed in bytes. The process of taking analog data, such as sound, and making it digital is called analog to digital conversion. Many music CD's from old original analog recordings on tapes were converted to digital to be placed on a CD (a CD is digital; it is just a collection of bits with a small hole burned in the CD representing a 1 and no hole representing a 0). Current music CD's have the analog to digital conversion done in the recording equipment itself, which produces better conversion. To convert an analog wave into digital, converters use a process called sampling. They sample the height of the sound wave at regular intervals of time, often small fractions of a second. If one byte is used to hold a single sample of an analog wave, then the wave can be one of 256 different heights (0 being the lowest height and 255 being the highest). These heights represent the decibel level of the sound. Thus a spoken word might occupy several hundred bytes - each being a sample of the sound wave of the voice at a small fraction of a second. If these 100 bytes were sent to a computer's speaker, the spoken word would be reproduced. Like ASCII for characters and GIF and JPEG for pictures, sound has several agreed-upon formats for representing samples in bytes. WAV is a common format on the Internet.  Program: collection of instructions that someone wrote to tell the computer to perform the task that the software is meant to do. Each instruction is a byte, or a small collection of bytes. If a computer used one byte for an instruction, it could have up to 256 instructions. Later we will look at what these instructions are, but for now, you should realize that a byte could also be a computer's instruction. The conversion of instructions to bytes is shown in Figure below. The programming process allows humans to write instructions in an English-like way. A software program called a compiler then transforms the English-like text into the bytes for instructions that the computer understands.
  • 5. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 5 Data Representation Like all other kinds of data, there are agreed-upon formats for computer instructions too. One reason that Macintosh computer programs do not run natively on PC-compatible (Intel-based) computers, is that Macintoshes and Intel PCs use different formats for coding instructions in bytes.  Integers: integer numbers are represented by counting in binary. In decimal we start from 0 to count and when we reach 9 the end of decimal place and we use two digits to count by putting a digit in the “tens place” and starting over again using our 10 digits. Thus, the decimal number 10 is a 1 in the “tens place” and a zero in the “ones place”. And if we need three digits, like 122, we use a third digit in the “hundred’s place”. We do a similar thing to count in binary- except now we only have two digits: 0 and 1. So we start with 0, then 1, then we run out of digits, so we need to use two digits to keep counting. We do this by putting a 1 in the “two’s place” and then using our two digits. Thus two is 10 binary: a 1 in the “two’s place” and a 0 in the “one’s place”. Three is 11: a 1 in the “two’s place” and a 1 in the “one’s place”. We run out of digits again! Thus, four is 100: a 1 in the” four’s place” a 0 in the “two’s place” a 0 in the “one’s place”.  How Does The Computer Know What a Byte Represents? We have seen that the byte: 01000011 can represent the integer 67, the character 'C', a pixel with darkness level 67, a sample of a sound with decibel level 67, or an instructions. There are other types of data that a byte can represent too. If that same byte can be all of those different types of data, how does the computer know what type it is? The answer is the context in which the computer uses the byte. If it sends the byte to a speaker, the 67th level of sound is produced. If it sends the byte to a monitor or printer, a pixel
  • 6. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 6 Data Representation with the 67th level of darkness is produced, etc. More accurately, if the byte were coded with a standard coding technique, like ASCII for characters, GIF for pictures, and WAV for sounds, then when the computer sends the byte to a device, the data corresponding to that coding is produced by the device. Number system 1. Decimal : base (radix) is 10 2. Hexal : base (radix) is 16 3. Octal : base (radix) is 8 4. Binary : base (radix) is 2 They are the way of number representation. However, in computer only binary can be use and other must converted into this binary. It has proved difficult to develop devices that can understand natural language directly due to the complexity of natural languages. However, it is easier to construct electric circuits based on the binary or ON and OFFlogic. All forms of data can be represented in binary system format. Other reasons for the use of binary are that digital devices are more reliable, small and use less energy as compared to analog devices. This is the main reason to study binary number system. 1. Decimal number system o The term decimal is derived from a Latin prefix deci, which means ten. Decimal number system has ten digits ranging from 0-9. Because this system has ten digits; it is also called a base ten number system or denary number system. o A decimal number should always be written with a subscript 10 e.g. X10 o But since this is the most widely used number system in the world, the subscript is usually understood and ignored in written work. However ,when many number systems are considered together, the subscript must always be put so as to differentiate the number systems. o The magnitude of a number can be considered using these parameters. o Absolute value o Place value or positional value o Base value  The absolute value is the magnitude of a digit in a number. for example the digit 5 in 7458 has an absolute value of 5 according to its value in the number line.  The place value of a digit in a number refers to the position of the digit in that number i.e. whether; tens, hundreds, thousands etc.  The total value of a number is the sum of the place value of each digit making the number.  The base value of a number also k known as the radix, depends on the type of the number systems that is being used .The value of any number depends on the radix. for example the number 10010 is not equivalent to 1002. 2. Binary number system
  • 7. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 7 Data Representation It uses two digits namely, 1 and 0 to represent numbers. unlike in decimal numbers where the place value goes up in factors of ten, in binary system, the place values increase by the factor of 2.binary numbers are written as X2.consider a binary number such as 10112.The right most digit has a place value of 1×20 while the left most has a place value of 1×23. 3. Octal number system Consists of eight digits ranging from 0-7.the place value of octal numbers goes up in factors of eight from right to left. 4. Hexadecimal number system This is a base 16 number system that consists of sixteen digits ranging from 0-9 and letters A-F where A is equivalent to 10,B to 11 up to F which is equivalent to 15 in base ten system. The place value of hexadecimal numbers goes up in factors of sixteen. A hexadecimal number can be denoted using 16 as a subscript or capital letter H to the right of the number .For example, 94B can be written as 94B16 or 94BH. Hexadecimal Decimal Octal Binary 00 00 0 0000 01 01 1 0001 02 02 2 0010 03 03 3 0011 04 04 4 0100 05 05 5 0101 06 06 6 0110 07 07 7 0111 08 08 1000 09 09 1001 A 10 1010 B 11 1011 C 12 1100 D 13 1101 E 14 1110 F 15 1111  Converting binary numbers to decimal numbers  To convert a binary number to a decimal number, we proceed as follows:  First, write the place values starting from the right hand side.  Write each digit under its place value.  Multiply each digit by its corresponding place value.  Add up the products. The answer will be the decimal number in base ten.
  • 8. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 8 Data Representation  EXAMPLE  Convert 1011012 to base 10(or decimal) number Place value 2524 232221 20 Binary digits 1 0 1 1 0 1  Multiply each digit by its place value N10=(1*25) +(0*24)+(1*23)+(1*22)+(0*21)+(1*20) N10=32+0+8+4+0+1 =4510  32*1=32  16*0=0  8*1=8 4*1=4  2*0=0  1*1=1  =4510  NB: remember to indicate the base subscript since it is the value that distinguishes the different systems.  Example  Convert 11.0112 to a decimal number.  Solution  Convert the integral and the fractional parts separately then add them up.  2×1= 2.000  1×1= +1.000  3.00010 Weight 21 20.2-12-2 2-3 Binary digit 1 1 .0 1 1 Values in base 102 1 .0 0.250.125  0.50×0 =0.000  0.25×1 =0.250  0.125×1=+0.125  0.37510  3.00010+0.37510= 3.37510  Thus 11.0112=3.37510  ) Converting a decimal to binary  Divide the integral part continuously by 2 till 1  Group the reminder from last to initial or first. This will give the binary equivalent.
  • 9. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 9 Data Representation  Example convert 39 to binary  And if the decimal number has fraction part multiply by 2 till fractional subsequent product is 0 or starts to repeat itself.  And grouping the carry (left of the decimal point) from first (beginning) to last (end).  Example : convert 0.625 to binary  0.625 x 2 = 1.25  0.25 with a carry of 1  0.25 x 2 = 0.50  0.50 with a carry of 0  0.50 x 2 = 1.00  0.00 with a carry of 1  0.625 = 0.101  If the decimal is like 39.625 and need to convert binary. This can be done by separating before the decimal and after the decimal then combine. 100111.101  Converting octal to binary  Working from left to the right, each octal number is represented using three digits and then combined; we get the final binary equivalent.  Example convert 3218 to binary equivalent  3 = 011  2 = 010  1 = 001  Combining the three from left to right 011010001  Converting binary to octal  grouping the binary number by three digits starting from right to left and take its decimal equivalent  Example convert 011010001 to octal equivalent  011 = 3  010 = 2  001 = 1  Then 3218 is the equivalent octal.  Converting hexadecimal to binary  Working from left to the right, each hexa number is represented using four digits and then combined; we get the final binary equivalent.
  • 10. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 10 Data Representation  Example convert D1 to binary equivalent  D = 1101  1 = 0001  Combining the two from left to right 11010001  Converting binary to hexadecimal  Grouping the binary number by four digits from right to left and take its decimal equivalent  Example convert 11010001 to hexadecimal equivalent  1101 = D  0001 = 1  Then D116 is the hexa equivalent  Converting octal to decimal  The same steps binary to decimal conversion except radix difference  Example convert 5128 to decimal equivalent Place value 82 81 80 648 1 Octal digit 5 1 2  Write each number under its place value as shown below  Multiply each number by its place value.  Converting hexadecimal numbers to decimal number To convert hexadecimal number to base 10 equivalent we proceed as follows: First, write the place values starting from the right hand side. 1. If a digit is a letter such as ‘A’ write its decimal equivalent  Multiply each hexadecimal digit with its corresponding place value and then add the products N10=(5 x 82)+(1 x 81 )+(2 x 80 ) =(5 x 64)+8+2 =320+8+2 N10=33010
  • 11. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 11 Data Representation  The following examples illustrate how to convert hexadecimal number to a decimal number Example Convert the hexadecimal number 11116 to its binary equivalent Solution Place each number under its place value. 162161 160 1 1 1 256 x1= 256 16 x 1 = 16 1 x 1= + 1 273 Therefore 11116 =27310  Binary arithmetic operations  In mathematics, the four basic arithmetic operations applied on numbers are addition, subtracstion, multiplications and division.  In computers, the same operations are performed inside the central processing unit by the arithmetic and logic unit (ALU). However, the arithmetic and logic unit cannot perform binary subtractions directly. It performs binary subtractions using a process known as for multiplication and division, the arithmetic and logic unit uses a method called shifting before adding the bits.  Representation of number as an integer:  When an integer binary number is positive, the sign is represented by 0 and the magnitude by a positive binary number.  When the number is negative, the sign is represented by 1 but the rest of the number may be represented in one of three possible ways: 1. Signed magnitude representation 2. Signed 1’s complement representation 3. Signed 2’s complement representation
  • 12. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 12 Data Representation Example: Consider the signed number 14 stored in an 8 bit register. +14 is represented by a sign bit of 0 in the leftmost position followed by the binary equivalent of 14  00001110. Note that each of the eight bits of the register must have a value and, therefore, 0’s must be inserted in the most significant positions following the sign bit. Although there is only one way to represent +14, there are three different ways to represent -14 with eight bits. Sign bit In signed magnitude representation 1 0001110 In signed 1’s complement representation 1 1110001 In signed 2’s complement representation 1 1110010 The signed magnitude representation of -14 is obtained from +14 by complementing only the sign bit. The signed 1’s complement representation of -14 is obtained by complementing all the bits of +14, including the sign bit. The signed 2’s complement representation is obtained by taking the 2’s complement of the positive number, including its sign bit. 1. Signed magnitude representation In this representation if we have n digits the absolute value is 2n-1and 1 digit for sign 0 for positive or 1 for negative. And zero has two representation both positive and negative. This ambiguity make its method slow. For example if you have 4 bits representation in signed magnitude as follows: 0 0000 1000 -0 1 0001 1001 -1 2 0010 1010 -2 3 0011 1011 -3 4 0100 1100 -4 5 0101 1101 -5 6 0110 1110 -6 7 0111 1111 -7  Performing arithmetic from this representation is difficult and dependent on the sign bit which is the left most bit if it is 0 the number is positive and if it is 1 the number is negative.  Because of these ambiguity and complexity it is not use todays.  Example : 1-6  1 == 0001  -6== 1110  Sum==1111-7 but the result must be -5 this is why this method is complex. However, if the numbers are both positive no problem can add simply.  Example 5 +6
  • 13. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 13 Data Representation  5 === 0101  6 ===0110  Sum =1011 2. Signed 1’s complement representation  This method can minimize the drawback of signed magnitude problems. Even though it has its own drawback that is delay of operation.  1’s complement of the number can be obtained by changing the bit that is 1 into 0, 0 into 1 or subtract all bits from all 1’s.  Example 1’s complement of 0 in four bits is 1111. How?  0 in four bits is = 0000  The change 0 into 1 = 1111  Or subtract from all 1’s  1111 - 0000 1111 which is the same result. 0 0000 1000 -7 1 0001 1001 -6 2 0010 1010 -5 3 0011 1011 -4 4 0100 1100 -3 5 0101 1101 -2 6 0110 1110 -1 7 0111 1111 -0  Example 6-2 which is equal to 6+(-2)  6 == 0110  -2 == 1101  Result =10011. There is carry bit and it has to be add from right side.  Therefore 0011 +1 is 0100 the correct answer.  These adding of carry bit causes delay and decrease the performance. So we need other method better than this that is 2’s complement. 3. Signed 2’s complement representation  This representation can solve the drawback of the two method those described above.  The first bit absolute value is negative such as -0000  -1 * 23+ 0*22+0 * 21+ 0*20 = -8 like this the following four bits example has given for further examples in 2’s complement.
  • 14. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 14 Data Representation -23222120 -23222120 0 0000 1000 -8 1 0001 1001 -7 2 0010 1010 -6 3 0011 1011 -5 4 0100 1100 -4 5 0101 1101 -3 6 0110 1110 -2 7 0111 1111 -1  Example 6-2 which is 6+(-2)  6 = 0110  -2 = 1110, that is different in signed magnitude, 1’s complement and here and the best method is this one.  Therefore 6 + (-2) is 10100 there is carry and you have to discard it rather than adding again like in 1’s compliment operation.  So addition and subtraction can done like these. The expression is like X – Y = X + (-Y) . Note: Generally Complement is r complement and r-1 complement. The r complement such as 10 for decimal or 2 for binary number system and r-1 complement such as 9 complement for decimal and 1 complement for binary number systems.  9’complement: To form the 9’s complement of decimal number each digit of a decimal number is subtracted from 9. The result so obtained is known as 9’s complement of the number. Ex: Find 9’s complement of decimal number 37(10) Sol : 37(10) = 9’s complement ? 9’s complement of 37 is 99 – 37 = 62. Like that…3977(10) = 9’s complement ? 9’s complement of 3977 is 9999 – 3977 = 6022.  10’s complement: The 10’s complement of a decimal number is equal to the 9’s complement of the number plus 1. 10’s complement of 37 is 99 – 37 = 62 +1 = 63. Overflow: When two numbers of n digits each are added and the sum occupies n+1 digits, we say that an overflow occurred. An overflow is a problem in digital computers because the width of registers is finite.
  • 15. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 15 Data Representation A result that contains n+1 bits cannot be accommodated in a register with a standard length of n bits. For this reason, many computers detect the occurrence of an overflow, and when it occurs, a corresponding flip-flop is set which can then be checked by the user.  An overflow may occur if the two numbers added are both positive and both negative. Example: Two signed binary numbers, +70 and +80, are stored in two 8bit registers. carries : 0 1 carries: 1 0 +70 0 1000110 -70 1 0111010 +80 0 1010000 -80 1 0110000 +150 1 0010110 -150 0 1101010 Note that the 8 bit result that should have been positive has a negative sign bit and the 8bit result that should have been negative has a positive sign bit. If, however, the carry out of the sign bit position is taken as the sign bit of the result, the 9 bit answer so obtained will be correct. Since the answer cannot be accommodated within 8 bits, we say that an overflow occurred. If the two carries are applied to an exclusive-OR gate, an overflow will be detected when the output of the gate is equal to 1.  Floating-Point Representation In this representation decimal numbers are represented with a fixed length format. In order not to waste bits, the representation will normalize all the numbers. For example, 0.000123 wastes three zeroes on the left before non -zero digits. These zeroes have no meaning except to indicate the position of the Decimal point. Normalizing this number result in .123x10-3 .123 is the normalized mantissa; -3 is the exponent. We have normalized this by eliminating all the meaningless zeroes to the left of the first non-zero digit and by adjusting the exponent. Ex1: 22.1 is normalized as .221x102. The general form of floating point representation is Mx10E where M is the mantissa, and E is the exponent. It can be seen that a normalized number is characterized by a mantissa less than 1 and greater than or equal to.1 all cases when the number is not zero. To represent floating numbers in the computer system it should be normalized after converting to binary number representation system.
  • 16. Samara University College of Engineering and Technology Department of Information Technology ==================================================================================== GIRMACHEW 16 Data Representation Ex2 111.01 is normalized as .11101x23. The mantissa is 11101. The exponent is 3. The general structure of floating point is Sign Exponent Mantissa (significand) In representing a number in floating point we use 1 bit for sing, some bits for exponent and the remaining bit for mantissa.  Fixed Point Representation Positive Integers, including zero, can be represented as unsigned numbers. However, to represent negative integers, we need a notation for negative values. In ordinary arithmetic, a negative number is indicated by a minus sign and a positive number by a plus sign. Because of hardware limitations, computers must represent everything with 1’s and 0’s, including the sign of a number. As a consequence, it is customary to represent the sign with a bit placed in the leftmost position of the number. There are two ways of specifying the position of the binary point in a register by giving it a works using fixed position or by employing a floating point representation. The fixed point method assumes that the binary pint is always fixed in one position. The two positions most widely used are 1) A binary point in the extreme left of the register to make the stored number a fraction, and 2) A binary point in the extreme right of the register to make the stored number an integer.