You are on page 1of 71

DATA REPRESENTATION

COMP 212 COMPUTER FUNDAMENTALS AND PROGRAMMING


DATA

It refers to the symbols that represent people, events, things, and


ideas.

Data can be a name, a number, the colors in a photograph, or the


notes in a musical composition.
DATA REPRESENTATION

It refers to the form in which data is stored, processed, and


transmitted.

Devices such as smartphones, iPods, and computers store data in


digital formats that can be handled by electronic circuitry.
DIGITIZATION

The process of converting information, such as text, numbers,


photo, or music, into digital data that can be manipulated by
electronic devices.
BITS, BYTES, NIBBLES, AND WORD

They are used widely in reference to computer memory and data


size.

 BIT (b)
It is the basic unit of data or information in digital computers.
BITS, BYTES, NIBBLES, AND WORD

 BYTE (B)
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.
BITS, BYTES, NIBBLES, AND WORD

 NIBBLE
Half a byte, which is usually a grouping of 4 bits.
BITS, BYTES, NIBBLES, AND WORD

 WORD
Two or more bits make a word. It is the natural unit of data used by
a particular processor design.

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, or 64 bits


WHAT IS A NUMBER SYSTEM?

A way of representing numbers.

A set of values that are used to represent different quantities.

Example: Representation of RGB color model in a form of number


system
THE NUMBER SYSTEMS

 Base - 10
 Base - 8
 Base - 16
 Base - 2
BASE - 10

It is commonly known as decimal.

The decimal number system consists of ten digits from 0 to 9.

Example: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, …


VISUALIZING BASE - 10 (2347)
BASE – 10 MATHEMATICALLY (2347)

:
BASE - 8

It is commonly known as octal.

The system is based on the number eight.

It consists of eight digits from 0 to 7.

Example: 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, …


NOTES ON DIFFERENT BASES

Talking about numbers written in multiple bases can be confusing.

For example, 10 in base-8 is not the same as 10 in base-10.


NOTES ON DIFFERENT BASES

A standard notation where a subscript denotes the base of


numbers is needed.

For example, our base-8 version of 10 now looks like and our
base-10 version of 10 now looks like .
CONVERTING BASE - 8 TO BASE - 10

PROBLEM NO. 1

John offers to give you cookies, and Jane offers to give you
cookies.

Whose offer do you take?


CONVERTING BASE - 8 TO BASE - 10

As we saw when counting, the four in represents the number


of groups of eight.

So, in total, we have four groups of eight and seven groups of one.
CONVERTING BASE - 8 TO BASE - 10

Mathematically,

=
= +

So, cookies is the exact same as cookies. Jane’s offer


seems like the best one now!
CONVERTING BASE - 8 TO BASE - 10

PROBLEM NO. 2

The pattern we saw before with base-10 holds true here also. We’ll
look at .

There are five groups of , two groups of and three groups of


.
CONVERTING BASE - 8 TO BASE - 10

Mathematically,

= 0
=
= +
CONVERTING BASE - 8 TO BASE - 10

Visually,
TRY THIS

SEATWORK NO. 1.1

Convert the following Base - 8 digits to Base - 10.


1.
2.
3.
LET’S CHECK

SEATWORK NO. 1.1

Convert the following Base - 8 digits to Base - 10.


1. : =
=
= +
LET’S CHECK

2. : =
= +
LET’S CHECK

3. : =
=
=
= +
CONVERTING BASE - 10 TO BASE - 8

PROBLEM NO. 3

Let’s start with an example:

We first find the largest power of 8 that is smaller than our


number.

Here, this is or 64 because is 512, which is greater than 150.


CONVERTING BASE - 10 TO BASE - 8

We count how many groups of 64 we can take from 150.

This is 2, so the first digit in our base-8 number is 2.

We have now accounted for 128 out of 150, so we have 22 left


over.
CONVERTING BASE - 10 TO BASE - 8

The largest power of 8 that is smaller than 22 is (that is, 8).

How many groups of 8 can we take from 22?

Two groups again, and thus our second digit is 2.


CONVERTING BASE - 10 TO BASE - 8

Finally, we are left with 6, and can obviously take 6 groups of one
from this ( is 1), our final digit.

We end up with .
CONVERTING BASE - 10 TO BASE - 8

Mathematically,

=
=
=
TRY THIS

SEATWORK NO. 1.2

Convert the following Base - 10 digits to Base - 8.


1.
2.
3.
LET’S CHECK

SEATWORK NO. 1.2

Convert the following Base - 10 digits to Base - 8.


1. : =
=
=
LET’S CHECK

2. : =
=
LET’S CHECK

3. : =
=
=
=
=
BASE - 16

It is commonly known as hexadecimal.

It’s commonly used in computer programming, so it’s very


important to understand.

It consists of ten digits from 0 to 9 and six letter from the alphabet
from A to F.
Base 16 Digit Value
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
A 10
B 11
C 12
D 13
E 14
F 15
CONVERTING BASE - 16 TO BASE - 10

PROBLEM NO. 4

Let's convert to base-10 by following our previous rules.


CONVERTING BASE - 16 TO BASE - 10

Mathematically,

=
= + (D = 13)
TRY THIS

SEATWORK NO. 1.3

Convert the following Base - 16 digits to Base - 10.


1.
2.
3.
LET’S CHECK

SEATWORK NO. 1.3

Convert the following Base - 16 digits to Base - 10.


1. : = (A = 10)
= +
LET’S CHECK

2. : =
= (F = 15)
= +
LET’S CHECK

3. : =
=
= + (B = 11)
CONVERTING BASE - 10 TO BASE - 16

PROBLEM NO. 5

We can convert from base-10 to base-16 similar to the way we did


with base-8.

Let's convert to base-16.


CONVERTING BASE - 10 TO BASE - 16

First, we find the largest power of 16 that is less than . This is


, or 256. Then:

=
= (B = 11)
=

Final Answer :
TRY THIS

SEATWORK NO. 1.4

Convert the following Base - 10 digits to Base - 16.


1.
2.
3.
LET’S CHECK

SEATWORK NO. 1.4

Convert the following Base - 10 digits to Base - 16.


1. : =
= (F = 15)

Final Answer :
LET’S CHECK

2. : =
= (B = 11)

Final Answer :
LET’S CHECK

3. : =
=
= (E = 14)
= (B = 11)

Final Answer :
BASE - 2

It is commonly known as binary.

Digital computer represents all kinds of data and information in


the binary system.

While everyone knows binary is made up of 0s and 1s, it is


important to understand that it is no different mathematically than
any other base.
BASE - 2

Understanding binary is super important. The table below points


out digits’ values.

For example, the value of 10001 is 17, which is the sum of the
values of the two 1 digits (16+1).
CONVERTING BASE - 2 TO BASE - 10

PROBLEM NO. 6

First, we’ll convert to base-10. We have:


CONVERTING BASE - 2 TO BASE - 10

=
=
=
=
=
= +
CONVERTING BASE - 10 TO BASE - 2

PROBLEM NO. 7

Now let’s convert 65 to binary.

is the highest power of 2 less than 65, so:


CONVERTING BASE - 10 TO BASE - 2

=
=
=
=
=
=
=
TIPS AND TRICKS

Normally, when converting between two bases that aren’t base-


10, you would do something like this:

 Convert the number to base-10


 Convert the result to desired base
CONVERTING OTHER BASES

However, there’s a trick that will let you convert between binary
and hexadecimal quickly.

First, take any binary number and divide its digits into groups of
four.
CONVERTING OTHER BASES

PROBLEM NO. 8

So, say we have the number .

Divided up we have 0101 1101.


CONVERTING OTHER BASES

Notice how we can just add extra zeroes to the front of the first
group to make even groups of 4.

We now find the value for each group as if it was its own separate
number, which gives us 5 and 13.

Finally, we simply use the corresponding hexadecimal digits to


write out base-16 number, .
CONVERTING OTHER BASES

Visually,
CONVERTING OTHER BASES

PROBLEM NO. 9

We can go the other direction also, by converting each


hexadecimal digit into four binary digits.

Try converting to binary.


CONVERTING OTHER BASES

B = 11 7
= =
= =
= =
= =
CONVERTING OTHER BASES

This trick works because 16 is a power of 2.

What this means is that we use similar trick for base-8, which is
also a power of 2:
CONVERTING OTHER BASES
TRY THIS

SEATWORK NO. 1.5

Convert the following to the required bases.


1. to
2. to
3. to
LET’S CHECK

SEATWORK NO. 1.5

Convert the following to the required bases.


1. to =
=
= +
LET’S CHECK

2. to

4 3
= =
= =
= =
= =
LET’S CHECK

3. to

6 1
= =
= =
= =
LET’S CHECK

2 3
= =
= =
= =
TRY THIS

SEATWORK NO. 1.6

Convert the following to the required bases.


1. to
2. to
3. to

You might also like