number system & data representation

40
NUMBER SYSTEMS & DATA REPRESENTATIONS FUNDAMENTALS OF COMPUTER & PROGRAMMING (COMP 1) PREPARED BY: PHILLIP GLENN LIBAY

Upload: phillip-glenn-libay

Post on 18-Aug-2015

86 views

Category:

Data & Analytics


5 download

TRANSCRIPT

NUMBER SYSTEMS & DATA

REPRESENTATIONSFUNDAMENTALS OF COMPUTER & PROGRAMMING (COMP 1)

PREPARED BY: PHILLIP GLENN LIBAY

NUMBER SYSTEM

NUMBER SYSTEM

Is a method of expressing values, using a set of symbols in a consistent manner.

Several number systems has been used in the past which can be categorized into two (2): positional and non-positional number systems.

POSITIONAL NUMBER SYSTEM

POSITIONAL NUMBER SYSTEM

In a positional number system, the position the symbol occupies determines the value it represents, thus, it is also often called the PLACE VALUE system.

HOW DOES IT WORKS?

If number is represented as:

Then it has the value of:

DECIMAL number system

DECIMAL NUMBER SYSTEM

• Is a number system with the base of 10.

• It uses ten (10) unique symbols to represent values.

0 1 2 3 4 5 6 7 8 9

• n = 3, b = 10

• The equivalent decimal number is One Hundred Twenty Three

Example 1.a - Decimal Number System, Positional Values

BINARY number system

BINARY NUMBER SYSTEM

• Is a number system with the base of 2.

• It uses two (2) unique symbols to represent values.

0 1

• n = 4, b = 2

• The equivalent decimal number is Nine

Example 1.b - Binary Number System, Positional Values

OCTAL number system

OCTAL NUMBER SYSTEM

• Is a number system with the base of 8.

• It uses eight (8) unique symbols to represent values.

0 1 2 3 4 5 6 7

• n = 3, b = 8

• So the equivalent decimal number is Eighty Seven

Example 1.c - Octal Number System, Positional Values

HEXADECIMAL number system

HEXADECIMAL NUMBER SYSTEM

• Is a number system with the base of 16.

• It uses sixteen (16) unique symbols to represent values.

0 1 2 3 4 5 6 7 8 9 A B C D E F

• n = 3, b = 16

• So the equivalent decimal number is Two Hundred Eighty One

Example 1.d - Hexadecimal Number System, Positional Values

Decimal Binary Octal Hexadecimal

0 0 0 0

1 1 1 1

2 10 2 2

3 11 3 3

4 100 4 4

5 101 5 5

6 110 6 6

7 111 7 7

8 1000 10 8

9 1001 11 9

10 1010 12 A

11 1011 13 B

12 1100 14 C

13 1101 15 D

14 1110 16 E

15 1111 17 F

DECIMAL to BASE n conversions

START

Create an empty destination (v).

Divide the source (s) by the destination base (b).

Insert the remainder at the destination (v).

STOP

The quotient becomes the new source (s).

TRUE

FALSECondition: Is the quotient zero?

Given: s = Source Numberb = Destination Base

Return: v = Destination Value

Figure 1.a - Conversion from Decimal to any Base (Integral Part)

DECIMAL TO BINARY conversionINTEGRAL VALUES

Example 1.e - Decimal to Binary Conversion (Integral Values)

Convert the number to binary.

Results:

13

61 30

1011

Source

Destination

DECIMAL TO OCTAL conversionINTEGRAL VALUES

Example 1.f - Decimal to Octal Conversion (Integral Values)

Convert the number to octal.

Results:

12615

0 1

671

Source

Destination

DECIMAL TO HEXADECIMAL conversionINTEGRAL VALUES

Example 1.g - Decimal to Hexadecimal Conversion (Integral Values)

Convert the number to octal.

Results:

12670

E7

Source

Destination

START

Create an empty destination (v).

Multiply the source (s) by the destination base (b).

Insert the integral part at the destination (v).

STOP

The fractional part becomes the new source

(s).

TRUE

FALSECondition: Is the fractional part zero?

Given: s = Source Numberb = Destination Base

Return: v = Destination Value

Figure 1.b - Conversion from Decimal to any Base (Fractional Part)

DECIMAL TO BINARY conversionFRACTIONAL VALUES

Example 1.h - Decimal to Binary Conversion (Fractional Values)

Convert to Binary.

Results:

0.625 0.25 0.50 0.00

1 0 1

DECIMAL TO OCTAL conversionFRACTIONAL VALUES

Example 1.h - Decimal to Octal Conversion (Fractional Values)

Convert to Octal.

Results:

0.634 0.072 0.576 0.608

5 0 4

DECIMAL TO HEXADECIMAL conversionFRACTIONAL VALUES

Example 1.h - Decimal to Hexadecimal Conversion (Fractional Values)

Convert to Hexadecimal.

Results:

0.64 0.24 0.84 0.44

A 3 D

BINARY to OCTAL conversion

Figure 1.c - Binary to Octal Conversion

Binary Digit

Octal Digit

𝐵𝑚 𝐵𝑚−1 𝐵𝑚−2 𝐵5 𝐵4 𝐵3 𝐵2 𝐵1 𝐵0…

𝑂𝑚𝑂1 𝑂0

BINARY to HEXADECIMAL conversion

Binary Digit

Octal Digit

𝐵𝑚 𝐵𝑚−1 𝐵𝑚−2 𝐵𝑚−3 𝐵7 𝐵6 𝐵5 𝐵4 𝐵3 𝐵2 𝐵1 𝐵0…

𝐻𝑚𝐻1 𝐻0

OCTAL to HEXADECIMAL conversion

𝐻2 𝐻1𝐻0

1 0 0 1 1 0 1 0 1 0 1 0

𝑂3 𝑂2 𝑂1 𝑂0