### GE6151 Computer programming OCTAL NUMBERS

OCTAL NUMBERS

Like the hexadecimal system, the octal system provides a convenient way to express binary numbers and codes. However, it is used less frequently than hexadecimal in conjunction with computers and microprocessors to express binary quantities for input and output purposes.

The octal system is composed of eight digits, which are: 0, 1, 2, 3, 4, 5, 6, 7

To count above 7, begin another column and start over: 10, 11, 12, 13, 14, 15, 16, 17, 20, 21 and so on. Counting in octal is similar to counting in decimal, except that the digits 8 and 9 are not used.

OCTAL-TO-DECIMAL CONVERSION

Since the octal number system has a base of eight, each successive digit position is an increasing power of eight, beginning in the right-most column with 8º. The evaluation of an octal number in terms of its decimal equivalent is accomplished by multiplying each digit by its weight and summing the products.

Let‘s convert octal number 2374 in decimal number.

Weight 8³ 8² 81 80

Octal number 2 3 7 4

2374 = (2 x 8³) + (3 x 8²) + (7 x 81) + (4 x 8º) =1276

DECIMAL-TO-OCTAL CONVERSION

A method of converting a decimal number to an octal number is the repeated division-by-8

method, which is similar to the method used in the conversion of decimal numbers to binary or to hexadecimal.

Let‘s convert the decimal number 359 to octal. Each successive division by 8 yields a remainder that becomes a digit in the equivalent octal number. The first remainder generated is the least significant digit (LSD).

359/8 = 44.875 0.875 x 8 = 7 (LSD)

44 /8 = 5.5 0.5 x 8 = 4

5/8= 0.625 0.625 x 8 = 5 (MSD) The number is 547.

OCTAL-TO-BINARY CONVERSION

Because each octal digit can be represented by a 3-bit binary number, it is very easy to convert from octal to binary.

 Octal/Binary Conversion Octal Digit 0 1 2 3 4 5 6 7 Binary 000 001 010 011 100 101 110 111 Let‘s convert the octal numbers 25 and 140. Octal Digit 2 5 1 4 0 Binary 010 101 001 100 000

BINARY-TO-OCTAL CONVERSION

Conversion of a binary number to an octal number is the reverse of the octal-to-binary conversion.

Let‘s convert the following binary numbers to octal:

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

6 5 = 65 5 7 1 = 571

ALGORITHM

Algorithm

· Set of step-by-step instructions that perform a specific task or operation

· ―Natural‖ language NOT programming language

Pseudocode

· Set of instructions that mimic programming language instructions

Flowchart

· Visual program design tool

· ―Semantic‖ symbols describe operations to be performed

FLOWCHARTS

Definitions:

A flowchart is a schematic representation of an algorithm or a stepwise process, showing the steps

as boxes of various kinds, and their order by connecting these with arrows. Flowcharts are used in designing or documenting a process or program.

A flow chart, or flow diagram, is a graphical representation of a process or system that details the sequencing of steps required to create output.

A flowchart is a picture of the separate steps of a process in sequential order.