Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Octal
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Conversion between bases== ===Decimal to octal conversion=== ====Method of successive Euclidean division by 8==== To convert integer decimals to octal, [[Euclidean division|divide]] the original number by the largest possible power of 8 and divide the remainders by successively smaller powers of 8 until the power is 1. The octal representation is formed by the quotients, written in the order generated by the algorithm. For example, to convert 125<sub>10</sub> to octal: :125 = 8<sup>2</sup> Γ '''1''' + 61 :61 = 8<sup>1</sup> Γ '''7''' + 5 :5 = 8<sup>0</sup> Γ '''5''' + 0 Therefore, 125<sub>10</sub> = 175<sub>8</sub>. Another example: :900 = 8<sup>3</sup> Γ '''1''' + 388 :388 = 8<sup>2</sup> Γ '''6''' + 4 :4 = 8<sup>1</sup> Γ '''0''' + 4 :4 = 8<sup>0</sup> Γ '''4''' + 0 Therefore, 900<sub>10</sub> = 1604<sub>8</sub>. ====Method of successive multiplication by 8==== To convert a decimal fraction to octal, multiply by 8; the integer part of the result is the first digit of the octal fraction. Repeat the process with the fractional part of the result, until it is null or within acceptable error bounds. Example: Convert 0.1640625 to octal: :0.1640625βΓβ8 = 1.3125 = '''1''' + 0.3125 :0.3125βΓβ8 = 2.5 = '''2''' + 0.5 :0.5βΓβ8 = 4.0 = '''4''' + 0 Therefore, 0.1640625<sub>10</sub> = 0.124<sub>8</sub>. These two methods can be combined to handle decimal numbers with both integer and fractional parts, using the first on the integer part and the second on the fractional part. ====Method of successive duplication==== To convert integer decimals to octal, prefix the number with "0.". Perform the following steps for as long as digits remain on the right side of the radix: Double the value to the left side of the radix, using ''octal'' rules, move the radix point one digit rightward, and then place the doubled value underneath the current value so that the radix points align. If the moved radix point crosses over a digit that is 8 or 9, convert it to 0 or 1 and add the carry to the next leftward digit of the current value. ''Add'' ''octally'' those digits to the left of the radix and simply drop down those digits to the right, without modification. Example: <pre> 0.4 9 1 8 decimal value +0 --------- 4.9 1 8 +1 0 -------- 6 1.1 8 +1 4 2 -------- 7 5 3.8 +1 7 2 6 -------- 1 1 4 6 6. octal value </pre> ===Octal to decimal conversion=== To convert a number {{mvar|k}} to decimal, use the formula that defines its base-8 representation: :<math>k = \sum_{i=0}^n \left( a_i\times 8^i \right)</math> In this formula, {{math|''a''<sub>''i''</sub>}} is an individual octal digit being converted, where {{mvar|i}} is the position of the digit (counting from 0 for the right-most digit). Example: Convert 764<sub>8</sub> to decimal: :764<sub>8</sub> = 7βΓβ8<sup>2</sup> + 6βΓβ8<sup>1</sup> + 4βΓβ8<sup>0</sup> = 448 + 48 + 4 = 500<sub>10</sub> For double-digit octal numbers this method amounts to multiplying the lead digit by 8 and adding the second digit to get the total. Example: 65<sub>8</sub> = 6βΓβ8 + 5 = 53<sub>10</sub> ====Method of successive duplication==== To convert octals to decimals, prefix the number with "0.". Perform the following steps for as long as digits remain on the right side of the radix: Double the value to the left side of the radix, using ''decimal'' rules, move the radix point one digit rightward, and then place the doubled value underneath the current value so that the radix points align. ''Subtract'' ''decimally'' those digits to the left of the radix and simply drop down those digits to the right, without modification. Example: <pre> 0.1 1 4 6 6 octal value -0 ----------- 1.1 4 6 6 - 2 ---------- 9.4 6 6 - 1 8 ---------- 7 6.6 6 - 1 5 2 ---------- 6 1 4.6 - 1 2 2 8 ---------- 4 9 1 8. decimal value </pre> ===Octal to binary conversion=== To convert octal to binary, replace each octal digit by its binary representation. Example: Convert 51<sub>8</sub> to binary: :5<sub>8</sub> = 101<sub>2</sub> :1<sub>8</sub> = 001<sub>2</sub> Therefore, 51<sub>8</sub> = 101 001<sub>2</sub>. ===Binary to octal conversion=== The process is the reverse of the previous algorithm. The binary digits are grouped by threes, starting from the least significant bit and proceeding to the left and to the right. Add leading zeroes (or trailing zeroes to the right of decimal point) to fill out the last group of three if necessary. Then replace each trio with the equivalent octal digit. For instance, convert binary 1010111100 to octal: :{| border="1" cellspacing="0" cellpadding="4" |- align="center" | 001 || 010 || 111 || 100 |- align="center" | 1 || 2 || 7 || 4 |} Therefore, 1010111100<sub>2</sub> = 1274<sub>8</sub>. Convert binary 11100.01001 to octal: :{| border="1" cellspacing="0" cellpadding="4" |- align="center" | 011 || 100|| . || 010 || 010 |- align="center" | 3 || 4 || . || 2 || 2 |} Therefore, 11100.01001<sub>2</sub> = 34.22<sub>8</sub>. ===Octal to hexadecimal conversion=== The conversion is made in two steps using binary as an intermediate base. Octal is converted to binary and then binary to hexadecimal, grouping digits by fours, which correspond each to a hexadecimal digit. For instance, convert octal 1057 to hexadecimal: :To binary: :{| border="1" cellspacing="0" cellpadding="4" |- align="center" | 1 || 0 || 5 || 7 |- align="center" | 001 || 000 || 101 || 111 |} :then to hexadecimal: :{| border="1" cellspacing="0" cellpadding="4" |- align="center" | 0010 || 0010 || 1111 |- align="center" | 2 || 2 || F |} Therefore, 1057<sub>8</sub> = 22F<sub>16</sub>. ===Hexadecimal to octal conversion=== Hexadecimal to octal conversion proceeds by first converting the hexadecimal digits to 4-bit binary values, then regrouping the binary bits into 3-bit octal digits. For example, to convert 3FA5<sub>16</sub>: :To binary: :{| border="1" cellspacing="0" cellpadding="4" |- align="center" | 3 || F || A || 5 |- align="center" | 0011 || 1111 || 1010 || 0101 |} :then to octal: :{| border="1" cellspacing="0" cellpadding="4" |- align="center" | 0 || 011 || 111 || 110 || 100 || 101 |- align="center" | 0 || 3 || 7 || 6 || 4 || 5 |} Therefore, 3FA5<sub>16</sub> = 37645<sub>8</sub>.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Octal
(section)
Add topic