[go: up one dir, main page]

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

Lectures 5 Computer Data Representation

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

Lectures 5 Computer Data Representation

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

Forms of computer data

There are two classes of data, Analogue and Digital data

The forms of analogue data are Numerical or Text, Images, Sound and Videos.

For a computer data (analogue data) to be stored or process, it’s required to be converted in to
machine language (or digital data) (i.e. binary number 0 & 1).

Types of Data and Data storage in computer programing

DataType Machine language name Used: for storing and also for processing;
Integer int. whole numbers e.g. 1 4 3 6 1 etc

Real or Float Flt numbers that contain decimal point or for


fraction e.g. 4.1, 0.5, 100.6 etc

Character char. single letters e.g f, G, C, A, m, Q, h

String str Combination of any character that appears on a


key board, such as letters numbers and symbols.
E.g “Man”, “computer”, “school” “@”
“&”“B12”, “C6”, etc

Boolean bool It is used where data is restricted to True/False or


Yes/No

DATA STORAGE

All forms of data can either store as Variable or as Constant.

Constant are used in storing data that cannot be change thereafter

Variable are used in storing data that it value can be change later. The variable storage is name
depending on the data type it stored.

Example of variables storage Abdul


Musa Hauwa Mary “Rice”
5.1 R
5 Var. name = String or str.

Var. name = int. Var. name = float or real. Var. name = Character or char.

Abba

True/False

Var. name = Boolean


Variable location name on Data value Data type
storage
Musa 5 Integer (int.)

Magret 6.9 Float or real

Musa R Character (char)

Abdul Rice String (str)

Uzo True/False Boolean (bool)

COMPUTER DATA REPRESENTATION

Computers use binary - the digits 0 and 1 - to store data. A binary digit, or bit, is the smallest
unit of data in computing. It is represented by a 0 or a 1.

A collection of 8 bit is called byte (i.e. 1 byte = 8 bit)

To represent a counting number in binary

0 1 10 11 100 101 110 111 Base2 counting


0 1 2 3 4 5 6 7 Base10 counting

Concept of Binary Data storage and Representation

A computer’s memory is divided into tiny storage locations known as bytes. One byte is only
enough memory to store a letter of the alphabet or a small number. In order to do anything
meaningful, a computer has to have lots of bytes. Most computers today have millions, or even
billions, of bytes of memory. Each byte is divided into eight smaller storage locations known as
bits.

Computer scientists usually think of bits as tiny switches that can be either on or off. Bits aren’t
actual “switches,” however, at least not in the conventional sense. In most computer systems, bits
are tiny electrical components that can hold either a positive or a negative charge. Computer
scientists think of a positive charge as a switch in the on position, and a negative charge as a
switch in the off position. See fig. 1.1

When a piece of data is stored in a byte, the computer sets the eight bits to an on/off pattern that
represents the data. For example, the pattern shown on the left in Figure 1.2 shows how the
number A would be stored in a byte, and the pattern on the right shows how the letter 45 would
be stored in a byte. We explain below how these patterns are determined.
1 1

0 0

Fig 1.2 A = 01000001stored in byt 45 = 00101101 stored in byt

Storing Numbers

In computer systems, a bit that is turned off represents the number 0 and a bit that is turned on
represents the number 1. This corresponds perfectly to the binary numbering system. In the
binary numbering system, all numeric values are written as sequences of 0s and 1s. Here is an
example of a number that is written in binary: 10011101

The position of each digit in a binary number has a value assigned to it. Starting with the
rightmost digit and moving left, the position values are 2 0, 21, 22, 23, and so forth, as shown in
Figure 1.3.

1 0 0 1 1 1 0 1
20 = 1
21 = 2
22 = 4

23 = 8
24 = 16

25 = 32
26 = 64
27 = 128

To determine the value of a binary number you simply add up the position values of all the 1s.
For example, in the binary number 10011101, the position values of the 1s are 1, 4, 8,16, and
128. This is shown in Figure 1.3. The sum of all of these position values is 157. So, the value of
the binary number 10011101 is 157.

Therefore 1+4+8+16+128 =157

When all of the bits in a byte are set to 0 (turned off), then the value of the byte is 0. When all of
the bits in a byte are set to 1 (turned on), then the byte holds the largest value that can be stored
in it. The largest value that can be stored in a byte is 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 +
255. This limit exists because there are only eight bits in a byte.

What if you need to store a number larger than 255? The answer is simple: use more than one
byte. For example, suppose we put two bytes together. That gives us 16 bits. The position values
of those 16 bits would be 20, 21, 22, 23, and so forth, up through 215. As shown in Figure 1-13,
the maximum value that can be stored in two bytes is 65,535. If you need to store a number
larger than this, then more bytes are necessary.

Two bytes used for a large number

32768 + 16384 + 8192 + 4096 + 2048 + 1024 + 512 + 256 + 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1


= 65535

1 digit (1 bit) it’s a location on the computer storage that stores either 0 or 1. That is 1bit can
represent only two things 0 or 1. Another example human can represent male or female

Therefore 0 = male
1 = female
2 digit (2 bit) can represent four things for example Primary color are classify as Red, Blue,
Green and Yellow

That is 00 = Red 1

01 = Blue 2

10 = Green 3

11 = Yellow 4

Therefore n bit of information can represent 2n things

21 = 2 things

22 = 4 things

23 = 8 things

24 = 16 things

25 = 32 things

26 = 64 things

232 = 4,294,967,296 things


264 = 1.84467440737E19 things

How to represent text or Storing Character

When a character is stored in memory, it is first converted to a numeric code. The numeric code
is then stored in memory as a binary number.

A text document can be breakdown in to Character which is the smallest unit of text.

Paragraphs Sentences Words Character Representation in Binary num.

American standard code for information interchange (ASCII) is the key board used by a
computer, which allow up to 64 bit of data i.e. 264 = 1.84467440737E19 characters of data to be
store or process.

Each character on the button of computer keyboard has a digital or binary code that represents it.

Therefore Character Decimal numb. base 10 Representation in Binary num. base 2

Example using a table for ASCII character set write Amos


Character Decimal numb. represent Binary code (computer language)
A 65 01000001
m 109 01101101
o 111 01101111
s 115 01110011

Therefore Amos = 01000001011011010110111101110011

Example using a table for ASCII character set write Murtala


Character Decimal numb. represent Binary code (computer language)
M
u
r
t
a
l
a
REPRESENTING AUDIO DATA

Create sound from a speaker

We used electric signal to vibrate the membrane of a speaker to produce sound

An electric signal is passed through a wire coil, attached to a diaphragm and with a magnet fixed
within the coil which causes the diaphragm to move at the same frequency as the original sound
vibrates.
As the diaphragm moves it will cause the air around it to vibrate and will transmit sound waves
the same as the original sound wave which the reach our hear

How do we hear Audio Sound.

We hear an audio sound when a series of air compressed vibrate a membrane in our ear (ear
drum, ear fluid, hairy receptors), which sends electrical signals to our brain, t interpreat

The steps to convert electric signal producing audio sound to binary data as follows

I. We Sample the amplitude of the electrical signal every second 44,100 times per second
II. For each sample get the base 10 number for the amplitude
III. Convert the base 10 numbers to binary
IV. Save the binary file to a file e.g. mp3,
a

t
36 20 11 25 31 15 10 40 0000001000001110001110000

You might also like