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

Data Representation: Outline

The document discusses data representation in computers. It covers number systems like binary, octal, and hexadecimal used to represent numeric data. It also discusses how non-numeric data like text, images, sound are converted to numeric form using encoding schemes. Important goals of data representation like compactness, accuracy, ease of manipulation are highlighted. Common data types like integer, real, character that computers can handle efficiently are also mentioned.

Uploaded by

jpatr
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views

Data Representation: Outline

The document discusses data representation in computers. It covers number systems like binary, octal, and hexadecimal used to represent numeric data. It also discusses how non-numeric data like text, images, sound are converted to numeric form using encoding schemes. Important goals of data representation like compactness, accuracy, ease of manipulation are highlighted. Common data types like integer, real, character that computers can handle efficiently are also mentioned.

Uploaded by

jpatr
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 20

Data Representation

Outline:
Number systems
 binary
 octal
 hexadecimal
Representation of characters using codes
Other data types - audio, graphic, video
 Representation of no’s
 integer
 floating point
 Binary coded decimal
Programming languages and data types
Data representation

Human brain can process large variety of data


including:
 characters
 numbers
 images and sounds
 touch, smell and taste

Current technology limits data that computer can


efficiently manipulate to numeric data. Therefore,
ALL data - no matter how complex - must be
represented (encoded) in the computers memory
in numeric form.
Data Representation

Computers represent data using binary numbers


because:

 It is easy to represent binary numbers as electrical


states or signals which can be processed by two-
state (on-off) electrical devices

 It is easy to represent binary numbers as electrical


signals for moving between system components.
Data Representation

Refs: Burd , Chp 3.

Englander, Chps 2, 3,4 & 5


Number systems and computers

The BINARY number system is a positional number


system with similar properties to the decimal
system.

However, we often need to convert binary to a


number system we are familiar with (decimal) or a
system that is easier for humans to use.

Computer programs and data are often represented


using octal and hexadecimal number systems
because they are a short hand way of representing
binary numbers.
Number Systems - Decimal

The decimal system is a base-10 system. There are


10 distinct digits (0 to 9) to represent any quantity.
For an n-digit number, the value that each digit
represents depends on its weight or position. The
weights are based on powers of 10.

4TH. 3RD. 2ND. 1ST. POSITION

103 = 1000 102 = 100 101 = 10 100 = 1 WEIGHT

For example, 491610 = 4*1000 + 9*100 + 1*10 +6*1


Number Systems - Binary

The binary system is a base-2 system. There are 2


distinct digits (0 and 1) to represent any quantity.
For an n-digit number, the value that each digit
represents depends on its weight or position. The
weights are based on powers of 2.

8TH 7TH 6TH 5TH 4TH 3RD 2ND 1ST POSITION

27=128 26=64 25=32 24=16 23=8 22=4 21=2 20=1 WEIGHT

For example: 110100102 = 1*128 + 1*64 + 0*32 + 1*16 +


0*8 + 0*4 + 1*2 +0*1 = 21010
Number Systems - Octal
Octal and hexadecimal systems provide a
shorthand way to deal with the long strings of 1’s
and 0’s in binary.
Octal is a base-8 system using the digits 0 to 7. To
convert to decimal, you can again use a weighted
system eg.
 75128 = 7*83 + 5*82 + 1*81 + 2*80 = 391410
An octal number can easily be converted to binary
by replacing each octal digit with the
corresponding group of 3 binary digits.
Octal 0 1 2 3 4 5 6 7

Binary 000 001 010 011 100 101 110 111


Number Systems - Hexadecimal
The hexadecimal system is a base-16 system. It
contains the digits 0 to 9 and the letters A to F. The
letters A to F represent the decimal numbers 10 to
15.

Decimal Hexadecimal
0,1,2…9 0,1,2…..9
10 A
11 B
12 C
13 D
14 E
15 F
Number Systems - Hexadecimal

 This system is often used as a shorthand for the binary


number, especially for memory addresses. Each
hexadecimal digit = 4 binary digits .

 To convert to decimal, you can again use a weighted system.

3216 = ?

 Conversion to binary is done the same way as octal to


binary, but binary digits are organised into groups of 4.

 Conversion from binary to hexadecimal involves breaking


the bits into groups of 4 and replacing them with the
hexadecimal equivalent.
Hexadecimal - Binary Conversions

 HEX BINARY
0 0000 Hex to binary:
1 0001
2 0010
1D7F16 = 0001 1101 0111 11112
3 0011
5AB216 = 0101 1010 1011 00102
4 0100
5 0101
6 0110
7 0111 Binary to hex:
8 1000
9 1001 1110 0011 0000 11002 = E30C16
A 1010
B 1011 1001 1000 1101 111116 = 98DF16
C 1100
D 1101
E 1110
F 1111
Decimal to Base-n Conversions
To convert from decimal to a different number base
such as octal, binary or hexadecimal involves
repeated division by that number base.
 Keep dividing until the quotient is zero
 Use the remainders in reverse order
Decimal to Octal Decimal to Hex

8 |674 16 |735
8 |84  2 (*80) 16 |45  F (*160)
8 |10  4 (*81) 16 | 2  D (*161)
8 | 1  2 (*82) 16 | 0  2 (*162)
8 | 0  1 (*83) 0
0
Answer: 12428 Answer: 2DF16
Goals of Computer Data Representation

Compactness - compact data representation


requires less storage space and less expensive
processing and storage devices.

Accuracy - the accuracy of representation


increases with the number of data bits used.

Range – routine calculations can generate


quantities that are either too large or too small to
be stored within finite circuitry.
Goals of Computer Data Representation

Ease of manipulation - the efficiency of a processor


depends on its complexity.

Standardization - various organizations have


created standard data encoding methods for
communication among computer systems and their
components.

Some standards evolve from proprietary products


which become very popular. eg?
Data types

CPU will have instructions for dealing with limited


no of data types (primitives), based on these goals
of data representation. Usually these types are:
 Char
 Boolean (T/F)
 Integer
 Real
 Memory addresses

Recent processors include special instructions to


deal with multimedia data eg mmx extension and
may also include instructions for operating on BCD
data.
Data Representation

The binary number system can be used to


represent simple numbers like 7 (00000111) or 51
(00110011) by storing binary strings .

But how can we encode fractional numbers,


images, sound, text ?? We need standard encoding
systems for each type of data to change into
numeric form.
Alphanumeric Data

Alphanumeric (character) data such as names and


addresses are represented by assigning a unique
binary code or sequence of bits to represent each
character. As each character is entered from a
keyboard (or other input device) it is converted into
its binary code.

Character code sets contain two classes of codes:


 Printable (normal characters)
 Non-printable ie. characters used as control codes.
For example:
• CTRL G (beep)
• CTRL Z (end of file)
Alphanumeric Codes

There are three main coding methods in use:


 ASCII
 EBCDIC
 Unicode.

ASCII
 7-bit code (128 characters)
 has an extended 8-bit version
 used on PC’s and non-IBM mainframes
 Was widely used to transfer data from one computer
to another – now being replaced by unicode
ASCII Coding Examples
An ASCII subset
“CAB” = 43414216
Symbol Code
= 0100 0011 0100 0001 0100 00102
A 41
B 42 “F1” = 463116
C 43 = 0100 0110 0011 00012
D 44
E 45
F 46 “3415” = 3334313516
0 30 = 0011 0011 0011 0100 0011 0001
1 31 0011 01012
2 32
3 33 *Note that this is a text string and no
4 34 arithmetic may be done on it. A postcode
5 35 is a good example of storing numbers as
6 36
7 37 text.
Alphanumeric Codes

EBCDIC
 an 8-bit code (256 characters)
 used on mainframe IBM machines

Both ASCII and EBCDIC are 8 bit codes inadequate


for representing all international characters
eg Chinese characters

Unicode recent 16 bit standard - can represent 65


thousand characters, of which 49,000 have been
defined, incorporates ASCII-7 as subset.

You might also like