# Number Conversion - Decimal to Octal and Octal to Decimal

## Decimal to Octal:

Decimal (base-10) to octal (base-8) conversion:
Step 1: Divide the decimal number by 8 (8 comes from the base value of octal number system).
Step 2: The remainder is the LSD (least significant digit) of the octal number.
Step 3: Divide the quotient from Step 1 by 8 again.
Step 4: The new remainder from Step 3 is the next digit (from right to left) of the octal number.
Step 5: The process continues until we get 0 as the quotient. The remainder from this step is the MSD (most significant digit) of the octal number.

#### Example:

Decimal number: 4510
NumeratorDenominatorQuotientRemainder
45855 (LSD)
5805 (MSD)
So, the octal representation: 558

Decimal fraction to octal (base-8) conversion:
Step 1: Multiply the fraction number by 8 (8 comes from the base value of octal number system).
Step 2: The result (without the fraction part if any) is the MSD of the octal number.
Step 3: Take only the fraction part from Step 2 and multiply it by 8 again.
Step 4: The result (except the fraction part if any) from Step 3 is the next digit (from left to right) of the octal number.
Step 5: The process continues until we get X.00 as the final result (here X = any number from 0 to 7). From this step X is the LSD of the octal number.

#### Example:

Decimal number: 0.812510
StepsMultiplicandMultiplierResult (without fraction part)Result (only the fraction part)
1.812586 (MSB).5
2.584 (LSB).0
So, the octal representation: .648

#### [Integer + fraction] decimal to octal:

Decimal: 45.812510
Octal: 55.648

## Octal to Decimal:

Octal (base-8) to decimal (base-10) conversion:
From right (LSB) to left (MSB) we will take each digit and multiply them by 8x and later add the results together. Here x is the corresponding position of a digit and 8 comes from the base value of octal number system.

#### Example:

Octal number: 558
Number:5 (MSB)5 (LSB)
Position:10
(5 x 81) + (5 x 80)
= 40 + 5
= 45

So, the decimal representation: 4510

Octal fraction to decimal fraction conversion:
From left (MSB) to right (LSB) we will take each digit and multiply them by 8x and later add the results together. Here x is the corresponding position of a digit and 8 comes from the base value of octal number system.

#### Example:

Octal number: .648
Number:6 (MSB)4 (LSB)
Position:-1-2
(6 x 8-1) + (4 x 8-2)
= 0.75 + 0.0625
= 0.8125

So, the decimal representation: 0.812510

#### [Integer + fraction] octal to decimal:

Octal: 55.648
Decimal: 45.812510