Session 6 Data Representation
Session 6 Data Representation
Session 6 Data Representation
INTRODUCTION SESSION 6
OBJECTIVES
By the end of the lesson you should be able to:
• numbers
• text
• graphics of many varieties (stills, video, animation)
• sound
How can a sequence of 0's and 1's represent things as diverse as your
photograph, your favourite song, a recent movie, and your term paper?
Computers use a variety of different codes. Some are used for numbers,
others for text, and still others for sound and graphics
Numbering Systems
You've been using the decimal (base 10) numbering system for so long
that you probably take it for granted. When you see a number like "123",
you don't think about the value 123; rather, you generate a mental image
of how many items this value represents. In reality, however, the number
123 represents: 1*102 + 2 * 101 + 3*100 or 100+20+3
In the positional numbering system, each digit appearing to the left of the
decimal point represents a value between zero and nine times an
increasing power of ten. Digits appearing to the right of the decimal point
represent a value between zero and nine times an increasing negative
power of ten. For example, the value 123.456 means:
The binary numbering system works just like the decimal numbering
system, with two exceptions: binary only allows the digits 0 and 1 (rather
than 0-9), and binary uses powers of two rather than powers of ten.
• 210 =1024, 211=2048. So 1024 is the largest power of two less than
1359. Subtract 1024 from 1359 and begin the binary value on the
left with a "1" digit. Binary = "1", Decimal result is 1359 - 1024 =
335.
• The next lower power of two (29 = 512) is greater than the result
from above, so add a "0" to the end of the binary string.
Binary = "10", Decimal result is still 335.
• The next lower power of two is 256 (28). Subtract this from 335
and add a "1" digit to the end of the binary number.
Binary = "101", Decimal result is 79.
• 128 (27) is greater than 79, so tack a "0" to the end of the binary
string. Binary = "1010", Decimal result remains 79.
• The next lower power of two (26 = 64) is less than79, so subtract
64 and append a "1" to the end of the binary string. Binary =
"10101", Decimal result is 15.
• 15 is less than the next power of two (25 = 32) so simply add a "0"
to the end of the binary string. Binary = "101010", Decimal result
is still 15.
• 16 (24) is greater than the remainder so far, so append a "0" to the
end of the binary string. Binary = "1010100",
Decimal result is 15.
• 23 (eight) is less than 15, so stick another "1" digit on the end of
the binary string. Binary = "10101001", Decimal result is 7.
• 22 is less than seven, so subtract four from seven and append
another one to the binary string. Binary = "101010011",
decimal result is 3.
• 21 is less than three, so append a one to the end of the binary
string and subtract two from the decimal value.
Binary = "1010100111", Decimal result is now 1.
• Finally, the decimal result is one, which is 20, so add a final "1" to
the end of the binary string. The final binary result is
"10101001111"
Binary Formats
Any number of leading zero bits may precede the binary number without
changing its value.
In the United States, most people separate every three digits with a
comma to make larger numbers easier to read. For example,
1,023,435,208 is much easier to read and comprehend than 1023435208.
We'll adopt a similar convention in this text for binary numbers. We will
separate each group of four binary bits with an underscore. For example,
136 CCEUCC/Post- Diploma Degree in Basic Education
UNIT 1
INTRODUCTION SESSION 6
We often pack several values together into the same binary number. One
form of the 80x 86 MOV instructions uses the binary encoding 1011 0rrr
dddd dddd to pack three items into 16 bits: a five-bit operation code
(1_0110), a three-bit register field (rrr), and an eight-bit immediate value
(dddd_dddd). For convenience, we'll assign a numeric value to each bit
position. We'll number each bit as follows:
2) Each bit to the left is given the next successive bit number.
X7 X6 X5 X4 X3 X2 X1 X0
A 32-bit binary value uses bit positions zero through 31, etc.
Bit zero is usually referred to as the low order (L.O.) bit (some refer to
this as the least significant bit). The left-most bit is typically called the
high order (H.O.) bit (or the most significant bit). We'll refer to the
intermediate bits by their respective bit numbers.
Note:
Hexadecimal is often abbreviated as hex even though, technically
speaking, hex means base six, not base sixteen.
DATA ORGANIZATION
Bits
With a single bit you can represent any two distinct items. Examples
include zero or one true or false on or off male or female and right or
wrong. However you are not limited to representing binary data types
CCEUCC/Post- Diploma Degree in Basic Education 137
UNIT 1
SESSION 6 DATA REPRESENTATION
(that is those objects which have only two distinct values). You could use
a single bit to represent the numbers 723 and 1 245. Or perhaps 6 254
and 5. You could also use a single bit to represent the colours red and
blue. You could even represent two unrelated objects with a single bit.
Nibbles
Bytes
Without question the most important data structure used by the 80x86
microprocessor is the byte. A byte consists of eight bits and is the
smallest addressable datum (data item) on the 80x86 microprocessor.
Main memory and I/O addresses on the 80x86 are all byte addresses.
This means that the smallest item that can be individually accessed by an
80x 86 programs is an eight-bit value.
Words
Naturally a word may be further broken down into four nibbles as shown
below:
Self-Assessment Question
1. All data stored in the computer are in the form of 0’s and
1’s …………. (True/False)
2. The numbering system used by the computer is the
…………….
3. Arrange the following in order of hierarchy
Exercises: