Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Octal
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!
{{Short description|Base-8 numeral system}} {{Numeral systems for computation}} {{Use dmy dates|date=August 2019|cs1-dates=y}} {{Table Numeral Systems}} '''Octal''' ('''base 8''') is a [[numeral system]] with [[8 (number)|eight]] as the [[radix|base]]. In the decimal system, each place is a [[power of ten]]. For example: : <math>\mathbf{74}_{10} = \mathbf{7} \times 10^1 + \mathbf{4} \times 10^0</math> In the octal system, each place is a power of eight. For example: : <math>\mathbf{112}_8 = \mathbf{1} \times 8^2 + \mathbf{1} \times 8^1 + \mathbf{2} \times 8^0 </math> By performing the calculation above in the familiar decimal system, we see why 112 in octal is equal to <math>64+8+2=74</math> in decimal. Octal numerals can be easily converted from [[Binary numeral system|binary]] representations (similar to a [[quaternary numeral system]]) by grouping consecutive binary digits into groups of three (starting from the right, for integers). For example, the binary representation for decimal 74 is 1001010. Two zeroes can be added at the left: {{nowrap|(00)1 001 010}}, corresponding to the octal digits {{nowrap|1 1 2}}, yielding the octal representation 112. {| class="wikitable" style="float:right; text-align:center" |+ The octal [[multiplication table]] |- | × || '''1''' || '''2''' || '''3''' || '''4''' || '''5''' || '''6''' || '''7''' || '''10''' |- | '''1''' || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 10 |- | '''2''' || 2 || 4 || 6 || 10 || 12 || 14 || 16 || 20 |- | '''3''' || 3 || 6 || 11 || 14 || 17 || 22 || 25 || 30 |- | '''4''' || 4 || 10 || 14 || 20 || 24 || 30 || 34 || 40 |- | '''5''' || 5 || 12 || 17 || 24 || 31 || 36 || 43 || 50 |- | '''6''' || 6 || 14 || 22 || 30 || 36 || 44 || 52 || 60 |- | '''7''' || 7 || 16 || 25 || 34 || 43 || 52 || 61 || 70 |- | '''10''' || 10 || 20 || 30 || 40 || 50 || 60 || 70 || 100 |} ==Usage== ===In China=== [[File:Bagua-name-earlier.svg|right|thumb|250px|[[Fuxi]]'s "Earlier Heaven" Arrangement of the Eight Trigrams]] The eight [[bagua]] or trigrams of the [[I Ching]] correspond to octal digits: * 0 = ☷, 1 = ☳, 2 = ☵, 3 = ☱, * 4 = ☶, 5 = ☲, 6 = ☴, 7 = ☰. [[Gottfried Wilhelm Leibniz]] made the connection between trigrams, hexagrams and binary numbers in 1703.<ref>{{cite web |url=http://www.leibniz-translations.com/binary.htm |title=Explanation of binary arithmetic |last=Leibniz |first=Gottfried Wilhelm |date=1703 |website=leibniz-translations.com |access-date=2022-03-02 |archive-date=2021-02-11 |archive-url=https://web.archive.org/web/20210211112719/http://www.leibniz-translations.com/binary.htm |url-status=live }}</ref> ===By Native Americans=== * The [[Yuki language]] in [[California]] has an octal system because the speakers count using the spaces between their fingers rather than the fingers themselves.<ref>{{cite journal |jstor=2686959 |title=Ethnomathematics: A Multicultural View of Mathematical Ideas |issue=4 |pages=353–355 |author-first=Marcia |author-last=Ascher|author-link= Marcia Ascher |journal=The College Mathematics Journal|volume=23 |year=1992 |doi=10.2307/2686959 }}</ref> * The [[Pame language|Pamean languages]] in [[Mexico]] also have an octal system, because their speakers count on the knuckles of a closed fist.<ref>{{Cite journal | last=Avelino | first=Heriberto | title=The typology of Pame number systems and the limits of Mesoamerica as a linguistic area | journal=Linguistic Typology | year=2006 | volume=10 | issue=1 | pages=41–60 | url=http://linguistics.berkeley.edu/~avelino/Avelino_2006.pdf | doi=10.1515/LINGTY.2006.002 | s2cid=20412558 | access-date=2007-11-21 | archive-date=2011-06-04 | archive-url=https://web.archive.org/web/20110604174942/http://linguistics.berkeley.edu/~avelino/Avelino_2006.pdf | url-status=live }}</ref> ===By Europeans=== * It has been suggested that the reconstructed [[Proto-Indo-European|Proto-Indo-European (PIE)]] word for "nine" might be related to the PIE word for "new". Based on this, some have speculated that proto-Indo-Europeans used an octal number system, though the evidence supporting this is slim.<ref>{{cite book |last=Winter |first=Werner |chapter=Some thoughts about Indo-European numerals |title=Indo-European numerals |series=Trends in Linguistics |volume=57 |editor1-last=Gvozdanović |editor1-first=Jadranka |date=1991 |publisher=Mouton de Gruyter |location=Berlin |isbn=3-11-011322-8 |pages=13–14 |chapter-url=https://books.google.com/books?id=S-hmNOLuDGsC&pg=PA13 |access-date=2013-06-09 |archive-date=2023-04-01 |archive-url=https://web.archive.org/web/20230401131711/https://books.google.com/books?id=S-hmNOLuDGsC&pg=PA13 |url-status=live }}</ref> * In 1668, [[John Wilkins]] in ''[[An Essay towards a Real Character, and a Philosophical Language]]'' proposed use of base 8 instead of 10 "because the way of Dichotomy or Bipartition being the most natural and easie kind of Division, that Number is capable of this down to an Unite".<ref>{{cite book |last=Wilkins |first=John |title=An Essay Towards a Real Character and a Philosophical Language |date=1668 |location=London |pages=190 |url=https://books.google.com/books?id=BCCtZjBtiEYC&pg=PA190 |access-date=2015-02-08 |archive-date=2023-04-01 |archive-url=https://web.archive.org/web/20230401131651/https://books.google.com/books?id=BCCtZjBtiEYC&pg=PA190 |url-status=live }}</ref> * In 1716, King [[Charles XII of Sweden]] asked [[Emanuel Swedenborg]] to elaborate a number system based on 64 instead of 10. Swedenborg argued, however, that for people with less intelligence than the king such a big base would be too difficult and instead proposed 8 as the base. In 1718 Swedenborg wrote (but did not publish) a manuscript: "''En ny rekenkonst som om vexlas wid Thalet 8 i stelle then wanliga wid Thalet 10''" ("A new arithmetic (or art of counting) which changes at the Number 8 instead of the usual at the Number 10"). The numbers 1–7 are there denoted by the consonants l, s, n, m, t, f, u (v) and zero by the vowel o. Thus 8 = "lo", 16 = "so", 24 = "no", 64 = "loo", 512 = "looo" etc. Numbers with consecutive consonants are pronounced with vowel sounds between in accordance with a special rule.<ref>[[Donald Knuth]], ''[[The Art of Computer Programming]]''</ref> *Writing under the pseudonym "Hirossa Ap-Iccim" in ''[[The Gentleman's Magazine]]'', (London) July 1745, [[Hugh Jones (reverend)|Hugh Jones]] proposed an octal system for British coins, weights and measures. "Whereas reason and convenience indicate to us an uniform standard for all quantities; which I shall call the ''Georgian standard''; and that is only to divide every integer in each ''species'' into eight equal parts, and every part again into 8 real or imaginary particles, as far as is necessary. For tho' all nations count universally by ''tens'' (originally occasioned by the number of digits on both hands) yet 8 is a far more complete and commodious number; since it is divisible into halves, quarters, and half quarters (or units) without a fraction, of which subdivision ''ten'' is uncapable...." In a later treatise on [[Hugh Jones (reverend)#Publications|Octave computation]] (1753) Jones concluded: "Arithmetic by ''Octaves'' seems most agreeable to the Nature of Things, and therefore may be called Natural Arithmetic in Opposition to that now in Use, by Decades; which may be esteemed Artificial Arithmetic."<ref>See H. R. Phalen, "Hugh Jones and Octave Computation," ''The American Mathematical Monthly'' 56 (August–September 1949): 461-465.</ref> * In 1801, [[James Anderson of Hermiston|James Anderson]] criticized the French for basing the [[metric system]] on decimal arithmetic. He suggested base 8, for which he coined the term ''octal''. His work was intended as recreational mathematics, but he suggested a purely octal system of weights and measures and observed that the existing system of [[English units]] was already, to a remarkable extent, an octal system.<ref>James Anderson, On Octal Arithmetic [title appears only in page headers], [https://books.google.com/books?id=olhHAAAAYAAJ&pg=PA437 Recreations in Agriculture, Natural-History, Arts, and Miscellaneous Literature] {{Webarchive|url=https://web.archive.org/web/20230401131644/https://books.google.com/books?id=olhHAAAAYAAJ&pg=PA437 |date=2023-04-01 }}, Vol. IV, No. 6 (February 1801), T. Bensley, London; pages 437-448.</ref> * In the mid-19th century, Alfred B. Taylor concluded that "Our octonary [base 8] [[radix]] is, therefore, beyond all comparison the "''best possible one''" for an arithmetical system." The proposal included a graphical notation for the digits and new names for the numbers, suggesting that we should count "''un'', ''du'', ''the'', ''fo'', ''pa'', ''se'', ''ki'', ''unty'', ''unty-un'', ''unty-du''" and so on, with successive multiples of eight named "''unty'', ''duty'', ''thety'', ''foty'', ''paty'', ''sety'', ''kity'' and ''under''." So, for example, the number 65 (101 in octal) would be spoken in octonary as ''under-un''.<ref>Alfred B. Taylor, [https://archive.org/details/reportonweights00taylgoog Report on Weights and Measures], Pharmaceutical Association, 8th Annual Session, Boston, 1859-09-15. See pages 48 and 53.</ref><ref>Alfred B. Taylor, Octonary numeration and its application to a system of weights and measures, [https://books.google.com/books?id=KsAUAAAAYAAJ&pg=PA296 Proc. Amer. Phil. Soc. Vol XXIV] {{Webarchive|url=https://web.archive.org/web/20230401131638/https://books.google.com/books?id=KsAUAAAAYAAJ&pg=PA296 |date=2023-04-01 }}, Philadelphia, 1887; pages 296-366. See pages 327 and 330.</ref> Taylor also republished some of Swedenborg's work on octal as an appendix to the above-cited publications. ==={{anchor|\nnn}}In computers=== Octal became widely used in computing when systems such as the [[UNIVAC 1050]], [[PDP-8]], [[ICT 1900 series|ICL 1900]] and [[IBM mainframe]]s employed [[Six-bit character code|6-bit]], [[12-bit computing|12-bit]], [[24-bit computing|24-bit]] or [[36-bit computing|36-bit]] words. Octal was an ideal abbreviation of binary for these machines because their word size is divisible by three (each octal digit represents three binary digits). So two, four, eight or twelve digits could concisely display an entire [[Word (computer architecture)|machine word]]. It also cut costs by allowing [[Nixie tube]]s, [[seven-segment display]]s, and [[calculator]]s to be used for the operator consoles, where binary displays were too complex to use, decimal displays needed complex hardware to convert radices, and [[hexadecimal]] displays needed to display more numerals. All modern computing platforms, however, use 16-, 32-, or 64-bit words, further divided into [[octet (computing)|eight-bit bytes]]. On such systems three octal digits per byte would be required, with the most significant octal digit representing two binary digits (plus one bit of the next significant byte, if any). Octal representation of a 16-bit word requires 6 digits, but the most significant octal digit represents (quite inelegantly) only one bit (0 or 1). This representation offers no way to easily read the most significant byte, because it's smeared over four octal digits. Therefore, hexadecimal is more commonly used in programming languages today, since two hexadecimal digits exactly specify one byte. Some platforms with a power-of-two word size still have instruction subwords that are more easily understood if displayed in octal; this includes the [[PDP-11]] and [[Motorola 68000 family]]. The modern-day ubiquitous [[x86 architecture]] belongs to this category as well, but octal is rarely used on this platform, although certain properties of the binary encoding of opcodes become more readily apparent when displayed in octal, e.g. the ModRM byte, which is divided into fields of 2, 3, and 3 bits, so octal can be useful in describing these encodings. Before the availability of [[assembler (computing)|assembler]]s, some programmers would handcode programs in octal; for instance, Dick Whipple and John Arnold wrote [[Tiny BASIC|Tiny BASIC Extended]] directly in machine code, using octal.<ref>{{Cite journal |journal=[[Dr. Dobb's Journal|Dr. Dobb's Journal of Computer Calisthenics & Orthodontia, Running Light Without Overbyte]] |title=TB Code Sheet |volume=1 |issue=1 |date=December 1975}}</ref> Octal is sometimes used in computing instead of hexadecimal, perhaps most often in modern times in conjunction with [[file permissions]] under [[Unix]] systems (see [[chmod]]). It has the advantage of not requiring any extra symbols as digits (the hexadecimal system is base-16 and therefore needs six additional symbols beyond 0–9). In programming languages, octal [[literal (computer programming)|literal]]s are typically identified with a variety of [[prefix]]es, including the digit <code>0</code>, the letters <code>o</code> or <code>q</code>, the digit–letter combination <code>0o</code>, or the symbol <code>&</code><ref>{{cite book |chapter=Constants, Variables, Expressions and Operators |author=Microsoft Corporation |date=1987 |access-date=2015-12-12 |chapter-url=http://www.antonis.de/qbebooks/gwbasman/chapter%206.html |title=GW-BASIC User's Manual |url=http://www.antonis.de/qbebooks/gwbasman/ |archive-date=2016-01-05 |archive-url=https://web.archive.org/web/20160105062314/http://www.antonis.de/qbebooks/gwbasman/ |url-status=live }}</ref> or <code>$</code>. In ''Motorola convention'', octal numbers are prefixed with <code>@</code>, whereas a small (or capital<ref name="DRI_1983_CPM86-PG"/>) letter <code>o</code><ref name="DRI_1983_CPM86-PG"/> or <code>q</code><ref name="DRI_1983_CPM86-PG"/> is added as a [[suffix|postfix]] following the ''Intel convention''.<ref name="Kueveler-Schwoch_1996">{{cite book |title=Arbeitsbuch Informatik - eine praxisorientierte Einführung in die Datenverarbeitung mit Projektaufgabe |language=de |first1=Gerd |last1=Küveler |first2=Dietrich |last2=Schwoch |date=2013 |orig-year=1996 |publisher=Vieweg-Verlag, reprint: Springer-Verlag |isbn=978-3-528-04952-2 |id=978-3-32292907-5 |doi=10.1007/978-3-322-92907-5 |url=https://books.google.com/books?id=b8-dBgAAQBAJ |access-date=2015-08-05 |archive-date=2023-04-01 |archive-url=https://web.archive.org/web/20230401131645/https://books.google.com/books?id=b8-dBgAAQBAJ |url-status=live }}</ref><ref name="Kueveler-Schwoch_2007">{{cite book |title=Informatik für Ingenieure und Naturwissenschaftler: PC- und Mikrocomputertechnik, Rechnernetze |language=de |first1=Gerd |last1=Küveler |first2=Dietrich |last2=Schwoch |date=2007-10-04 |publisher=Vieweg, reprint: Springer-Verlag |edition=5 |volume=2 |isbn=978-3-83489191-4 |id=978-3-83489191-4 |url=https://books.google.com/books?id=xQbvPYxceY0C |access-date=2015-08-05 |archive-date=2023-04-01 |archive-url=https://web.archive.org/web/20230401131639/https://books.google.com/books?id=xQbvPYxceY0C |url-status=live }}</ref> In [[Concurrent DOS]], [[Multiuser DOS]] and [[REAL/32]] as well as in [[DOS Plus]] and [[DR-DOS]] various [[environment variable]]s like [[%$CLS%|$CLS]], [[%$ON%|$ON]], [[%$OFF%|$OFF]], [[%$HEADER%|$HEADER]] or [[%$FOOTER%|$FOOTER]]<!-- not all variables are supported by all of the mentioned OSes --> support an <code>\nnn</code> octal number notation,<ref name="Paul_1997_NWDOSTIP"/><ref name="Paul_2002_CLS"/><ref name="CCI_1997_HELP"/> and DR-DOS [[DEBUG]] utilizes <code>\</code> to prefix octal numbers as well. For example, the literal 73 (base 8) might be represented as <code>073</code>, <code>o73</code>, <code>q73</code>, <code>0o73</code>, <code>\73</code>, <code>@73</code>, <code>&73</code>, <code>$73</code> or <code>73o</code> in various languages. Newer languages have been abandoning the prefix <code>0</code>, as decimal numbers are often represented with leading zeroes. The prefix <code>q</code> was introduced to avoid the prefix <code>o</code> being mistaken for a zero, while the prefix <code>0o</code> was introduced to avoid starting a numerical literal with an alphabetic character (like <code>o</code> or <code>q</code>), since these might cause the literal to be confused with a variable name. The prefix <code>0o</code> also follows the model set by the prefix <code>0x</code> used for hexadecimal literals in the [[C (programming language)|C language]]; it is supported by [[Haskell (programming language)|Haskell]],<ref>{{cite web| url = https://www.haskell.org/onlinereport/lexemes.html#sect2.5| title = Haskell 98 Lexical Structure| access-date = 2019-11-01 | archive-date = 2021-04-11 | archive-url = https://web.archive.org/web/20210411061515/https://www.haskell.org/onlinereport/lexemes.html#sect2.5| url-status = live}}</ref> [[OCaml]],<ref>OCaml: [http://caml.inria.fr/pub/docs/manual-ocaml/lex.html 7.1 Lexical conventions] {{Webarchive|url=https://archive.today/20130701170755/http://caml.inria.fr/pub/docs/manual-ocaml/lex.html |date=2013-07-01 }}</ref> [[Python (programming language)|Python]] as of version 3.0,<ref>Python 3: https://docs.python.org/3.1/reference/lexical_analysis.html#integer-literals {{Webarchive|url=https://web.archive.org/web/20140320021754/http://docs.python.org/3.1/reference/lexical_analysis.html#integer-literals |date=2014-03-20 }}</ref> [[Raku (programming language)|Raku]],<ref>Perl 6: http://perlcabal.org/syn/S02.html#Radix_markers {{Webarchive|url=https://web.archive.org/web/20141031161348/http://perlcabal.org/syn/S02.html#Radix_markers |date=31 October 2014 }}</ref> [[Ruby (programming language)|Ruby]],<ref>RubySpec: https://github.com/ruby/ruby/blob/master/spec/ruby/core/string/to_i_spec.rb {{Webarchive|url=https://web.archive.org/web/20220529183751/https://github.com/ruby/ruby/blob/master/spec/ruby/core/string/to_i_spec.rb |date=2022-05-29 }}</ref> [[Tcl]] as of version 9,<ref>Tcl: http://wiki.tcl.tk/498 {{Webarchive|url=https://web.archive.org/web/20140104045014/http://wiki.tcl.tk/498 |date=2014-01-04 }}</ref> [[PHP]] as of version 8.1,<ref>PHP.Watch - PHP 8.1: Explicit Octal numeral notation https://php.watch/versions/8.1/explicit-octal-notation {{Webarchive|url=https://web.archive.org/web/20210108032852/https://php.watch/versions/8.1/explicit-octal-notation |date=2021-01-08 }}</ref> [[Rust (programming language)|Rust]]<ref>Rust literals and operators: https://doc.rust-lang.org/rust-by-example/primitives/literals.html {{Webarchive|url=https://web.archive.org/web/20220528081546/https://doc.rust-lang.org/rust-by-example/primitives/literals.html |date=2022-05-28 }}</ref> and [[ECMAScript]] as of ECMAScript 6<ref>ECMAScript 6th Edition draft: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-numeric-literals {{Webarchive|url=https://web.archive.org/web/20131216202526/https://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-numeric-literals |date=16 December 2013 }}</ref> (the prefix <code>0</code> originally stood for base 8 in [[JavaScript]] but could cause confusion,<ref>{{cite web |url=https://stackoverflow.com/questions/5600366/why-does-the-radix-for-javascripts-parseint-default-to-8 |title=Why does the radix for JavaScript's parseInt default to 8? |date=8 April 2011 |work=Stack Overflow |access-date=2019-08-21 |archive-date=2020-08-06 |archive-url=https://web.archive.org/web/20200806000322/https://stackoverflow.com/questions/5600366/why-does-the-radix-for-javascripts-parseint-default-to-8 |url-status=live }}</ref> therefore it has been discouraged in ECMAScript 3 and dropped in ECMAScript 5<ref>{{citation |work=Mozilla Developer Network (MDN) |title=parseInt() |url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt |quote=If the input string begins with "0" (a zero), radix is assumed to be 8 (octal) or 10 (decimal). Exactly which radix is chosen is implementation-dependent. ECMAScript 5 clarifies that 10 (decimal) should be used, but not all browsers support this yet |access-date=2014-01-03 |archive-date=2014-03-05 |archive-url=https://web.archive.org/web/20140305220352/https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt |url-status=live }}</ref>). Octal numbers that are used in some programming languages (C, [[Perl]], [[PostScript]]...) for textual/graphical representations of byte strings when some byte values (unrepresented in a code page, non-graphical, having special meaning in current context or otherwise undesired) have to be to [[escape character|escaped]] as <code>\nnn</code>. Octal representation may be particularly handy with non-ASCII bytes of [[UTF-8]], which encodes groups of 6 bits, and where any start byte has octal value <code>\3nn</code> and any continuation byte has octal value <code>\2nn</code>. Octal was also used for [[Floating-point arithmetic|floating point]] in the [[Ferranti Atlas]] (1962), [[Burroughs B5500]] (1964), [[Burroughs B5700]] (1971), [[Burroughs B6700]] (1971) and [[Burroughs B7700]] (1972) computers.<!-- list from note NB_9 in [[Floating-point arithmetic]] --> === In aviation === [[Transponder (aeronautics)|Transponders]] in aircraft transmit a "squawk" [[Transponder (aeronautics)#Transponder codes|code]], expressed as a four-octal-digit number, when interrogated by ground radar. This code is used to distinguish different aircraft on the radar screen. ==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>. ==Real numbers== ===Fractions=== Due to having only factors of two, many octal fractions have repeating digits, although these tend to be fairly simple: {|class="wikitable" | colspan="3" align="center" | Decimal base<br><SMALL>Prime factors of the base: <span style="color:Green">'''2'''</span>, <span style="color:Green">'''5'''</span></SMALL><br><SMALL>Prime factors of one below the base: <span style="color:Blue">'''3'''</span></SMALL><br><SMALL>Prime factors of one above the base: <span style="color:Magenta">'''11'''</span></SMALL><br><SMALL>Other Prime factors: <span style="color:Red">'''7 13 17 19 23 29 31'''</span></SMALL> | colspan="3" align="center" | '''Octal base'''<br><SMALL>Prime factors of the base: <span style="color:Green">'''2'''</span></SMALL><br><SMALL>Prime factors of one below the base: <span style="color:Blue">'''7'''</span></SMALL><br><SMALL>Prime factors of one above the base: <span style="color:Magenta">'''3'''</span></SMALL><br><SMALL>Other Prime factors: <span style="color:Red">'''5 13 15 21 23 27 35 37'''</span></SMALL> |- | align="center" | Fraction | align="center" | <SMALL>Prime factors<br>of the denominator</SMALL> | align="center" | Positional representation | align="center" | Positional representation | align="center" | <SMALL>Prime factors<br>of the denominator</SMALL> | align="center" | Fraction |- | align="center" | 1/2 | align="center" | <span style="color:Green">'''2'''</span> | '''0.5''' | '''0.4''' | align="center" | <span style="color:Green">'''2'''</span> | align="center" | 1/2 |- | align="center" | 1/3 | align="center" | <span style="color:Blue">'''3'''</span> | bgcolor=#c0c0c0 | '''0.'''3333... = '''0.'''{{overline|3}} | bgcolor=#c0c0c0 | '''0.'''2525... = '''0.'''{{overline|25}} | align="center" | <span style="color:Magenta">'''3'''</span> | align="center" | 1/3 |- | align="center" | 1/4 | align="center" | <span style="color:Green">'''2'''</span> | '''0.25''' | '''0.2''' | align="center" | <span style="color:Green">'''2'''</span> | align="center" | 1/4 |- | align="center" | 1/5 | align="center" | <span style="color:Green">'''5'''</span> | '''0.2''' | bgcolor=#c0c0c0 | '''0.'''{{overline|1463}} | align="center" | <span style="color:Red">'''5'''</span> | align="center" | 1/5 |- | align="center" | 1/6 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Blue">'''3'''</span> | bgcolor=#c0c0c0 | '''0.1'''{{overline|6}} | bgcolor=#c0c0c0 | '''0.1'''{{overline|25}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Magenta">'''3'''</span> | align="center" | 1/6 |- | align="center" | 1/7 | align="center" | <span style="color:Red">'''7'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|142857}} | bgcolor=#c0c0c0 | '''0.'''{{overline|1}} | align="center" | <span style="color:Blue">'''7'''</span> | align="center" | 1/7 |- | align="center" | 1/8 | align="center" | <span style="color:Green">'''2'''</span> | '''0.125''' | '''0.1''' | align="center" | <span style="color:Green">'''2'''</span> | align="center" | 1/10 |- | align="center" | 1/9 | align="center" | <span style="color:Blue">'''3'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|1}} | bgcolor=#c0c0c0 | '''0.'''{{overline|07}} | align="center" | <span style="color:Magenta">'''3'''</span> | align="center" | 1/11 |- | align="center" | 1/10 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Green">'''5'''</span> | '''0.1''' | bgcolor=#c0c0c0 | '''0.0'''{{overline|6314}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Red">'''5'''</span> | align="center" | 1/12 |- | align="center" | 1/11 | align="center" | <span style="color:Magenta">'''11'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|09}} | bgcolor=#c0c0c0 | '''0.'''{{overline|0564272135}} | align="center" | <span style="color:Red">'''13'''</span> | align="center" | 1/13 |- | align="center" | 1/12 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Blue">'''3'''</span> | bgcolor=#c0c0c0 | '''0.08'''{{overline|3}} | bgcolor=#c0c0c0 | '''0.0'''{{overline|52}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Magenta">'''3'''</span> | align="center" | 1/14 |- | align="center" | 1/13 | align="center" | <span style="color:Red">'''13'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|076923}} | bgcolor=#c0c0c0 | '''0.'''{{overline|0473}} | align="center" | <span style="color:Red">'''15'''</span> | align="center" | 1/15 |- | align="center" | 1/14 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Red">'''7'''</span> | bgcolor=#c0c0c0 | '''0.0'''{{overline|714285}} | bgcolor=#c0c0c0 | '''0.0'''{{overline|4}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Blue">'''7'''</span> | align="center" | 1/16 |- | align="center" | 1/15 | align="center" | <span style="color:Blue">'''3'''</span>, <span style="color:Green">'''5'''</span> | bgcolor=#c0c0c0 | '''0.0'''{{overline|6}} | bgcolor=#c0c0c0 | '''0.'''{{overline|0421}} | align="center" | <span style="color:Magenta">'''3'''</span>, <span style="color:Red">'''5'''</span> | align="center" | 1/17 |- | align="center" | 1/16 | align="center" | <span style="color:Green">'''2'''</span> | '''0.0625''' | '''0.04''' | align="center" | <span style="color:Green">'''2'''</span> | align="center" | 1/20 |- | align="center" | 1/17 | align="center" | <span style="color:Red">'''17'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|0588235294117647}} | bgcolor=#c0c0c0 | '''0.'''{{overline|03607417}} | align="center" | <span style="color:Red">'''21'''</span> | align="center" | 1/21 |- | align="center" | 1/18 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Blue">'''3'''</span> | bgcolor=#c0c0c0 | '''0.0'''{{overline|5}} | bgcolor=#c0c0c0 | '''0.0'''{{overline|34}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Magenta">'''3'''</span> | align="center" | 1/22 |- | align="center" | 1/19 | align="center" | <span style="color:Red">'''19'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|052631578947368421}} | bgcolor=#c0c0c0 | '''0.'''{{overline|032745}} | align="center" | <span style="color:Red">'''23'''</span> | align="center" | 1/23 |- | align="center" | 1/20 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Green">'''5'''</span> | '''0.05''' | bgcolor=#c0c0c0 | '''0.0'''{{overline|3146}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Red">'''5'''</span> | align="center" | 1/24 |- | align="center" | 1/21 | align="center" | <span style="color:Blue">'''3'''</span>, <span style="color:Red">'''7'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|047619}} | bgcolor=#c0c0c0 | '''0.'''{{overline|03}} | align="center" | <span style="color:Magenta">'''3'''</span>, <span style="color:Blue">'''7'''</span> | align="center" | 1/25 |- | align="center" | 1/22 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Magenta">'''11'''</span> | bgcolor=#c0c0c0 | '''0.0'''{{overline|45}} | bgcolor=#c0c0c0 | '''0.0'''{{overline|2721350564}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Red">'''13'''</span> | align="center" | 1/26 |- | align="center" | 1/23 | align="center" | <span style="color:Red">'''23'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|0434782608695652173913}} | bgcolor=#c0c0c0 | '''0.'''{{overline|02620544131}} | align="center" | <span style="color:Red">'''27'''</span> | align="center" | 1/27 |- | align="center" | 1/24 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Blue">'''3'''</span> | bgcolor=#c0c0c0 | '''0.041'''{{overline|6}} | bgcolor=#c0c0c0 | '''0.0'''{{overline|25}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Magenta">'''3'''</span> | align="center" | 1/30 |- | align="center" | 1/25 | align="center" | <span style="color:Green">'''5'''</span> | '''0.04''' | bgcolor=#c0c0c0 | '''0.'''{{overline|02436560507534121727}} | align="center" | <span style="color:Red">'''5'''</span> | align="center" | 1/31 |- | align="center" | 1/26 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Red">'''13'''</span> | bgcolor=#c0c0c0 | '''0.0'''{{overline|384615}} | bgcolor=#c0c0c0 | '''0.0'''{{overline|2354}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Red">'''15'''</span> | align="center" | 1/32 |- | align="center" | 1/27 | align="center" | <span style="color:Blue">'''3'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|037}} | bgcolor=#c0c0c0 | '''0.'''{{overline|022755}} | align="center" | <span style="color:Magenta">'''3'''</span> | align="center" | 1/33 |- | align="center" | 1/28 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Red">'''7'''</span> | bgcolor=#c0c0c0 | '''0.03'''{{overline|571428}} | bgcolor=#c0c0c0 | '''0.0'''{{overline|2}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Blue">'''7'''</span> | align="center" | 1/34 |- | align="center" | 1/29 | align="center" | <span style="color:Red">'''29'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|0344827586206896551724137931}} | bgcolor=#c0c0c0 | '''0.'''{{overline|0215173454106475626043236713}} | align="center" | <span style="color:Red">'''35'''</span> | align="center" | 1/35 |- | align="center" | 1/30 | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Blue">'''3'''</span>, <span style="color:Green">'''5'''</span> | bgcolor=#c0c0c0 | '''0.0'''{{overline|3}} | bgcolor=#c0c0c0 | '''0.0'''{{overline|2104}} | align="center" | <span style="color:Green">'''2'''</span>, <span style="color:Magenta">'''3'''</span>, <span style="color:Red">'''5'''</span> | align="center" | 1/36 |- | align="center" | 1/31 | align="center" | <span style="color:Red">'''31'''</span> | bgcolor=#c0c0c0 | '''0.'''{{overline|032258064516129}} | bgcolor=#c0c0c0 | '''0.'''{{overline|02041}} | align="center" | <span style="color:Red">'''37'''</span> | align="center" | 1/37 |- | align="center" | 1/32 | align="center" | <span style="color:Green">'''2'''</span> | '''0.03125''' | '''0.02''' | align="center" | <span style="color:Green">'''2'''</span> | align="center" | 1/40 |} ===Irrational numbers=== The table below gives the expansions of some common [[irrational number]]s in decimal and octal. {| class="wikitable" ! rowspan=2 | Number ! colspan=2 | Positional representation |- ! Decimal ! Octal |- | [[Square root of 2|{{sqrt|2}}]] {{small|(the length of the [[diagonal]] of a unit [[Square (geometry)|square]])}} | {{val|1.414213562373095048}}... | 1.3240 4746 3177 1674... |- | [[Square root of 3|{{sqrt|3}}]] {{small|(the length of the diagonal of a unit [[cube]])}} | {{val|1.732050807568877293}}... | 1.5666 3656 4130 2312... |- | [[Square root of 5|{{sqrt|5}}]] {{small|(the length of the [[diagonal]] of a 1×2 [[rectangle]])}} | {{val|2.236067977499789696}}... | 2.1706 7363 3457 7224... |- | {{mvar|[[Golden ratio|φ]]}} {{small|1=(phi, the [[golden ratio]] = {{math|(1+{{radical|5}})/2}})}} | {{val|1.618033988749894848}}... | 1.4743 3571 5627 7512... |- | {{mvar|[[Pi|π]]}} {{small|(pi, the ratio of [[circumference]] to [[diameter]] of a circle)}} | {{val|3.141592653589793238462643}}<br>{{val|383279502884197169399375105}}... | 3.1103 7552 4210 2643... |- | {{mvar|[[E (mathematical constant)|e]]}} {{small|(the base of the [[natural logarithm]])}} | {{val|2.718281828459045235}}... | 2.5576 0521 3050 5355... |} ==See also== * {{Annotated link|Computer number format}} * [[Octal games]], a game numbering system used in [[combinatorial game theory]] * [[Split octal]], a 16-bit octal notation used by the Heath Company, DEC and others * [[Squawk code]], a 12-bit octal representation of [[Gillham code]] * [[Syllabic octal]], an octal representation of 8-bit syllables used by English Electric ==References== {{reflist|refs= <ref name="Paul_1997_NWDOSTIP">{{cite book |contribution=NWDOS-TIPs — Tips & Tricks rund um Novell DOS 7, mit Blick auf undokumentierte Details, Bugs und Workarounds |title=MPDOSTIP |author-first=Matthias R. |author-last=Paul |date=1997-07-30 |edition=3 |version=Release 157 |language=de |contribution-url=http://www.antonis.de/dos/dos-tuts/mpdostip/html/nwdostip.htm |access-date=2014-08-06 |url-status=live |archive-url=https://web.archive.org/web/20161104235829/http://www.antonis.de/dos/dos-tuts/mpdostip/html/nwdostip.htm |archive-date=2016-11-04}} (NB. NWDOSTIP.TXT is a comprehensive work on [[Novell DOS 7]] and [[OpenDOS 7.01]], including the description of many undocumented features and internals. It is part of the author's yet larger <code>MPDOSTIP.ZIP</code> collection maintained up to 2001 and distributed on many sites at the time. The provided link points to a HTML-converted older version of the <code>NWDOSTIP.TXT</code> file.)</ref> <ref name="Paul_2002_CLS">{{cite web |title=Updated CLS posted |author-first=Matthias R. |author-last=Paul |date=2002-03-26 |url=http://marc.info/?l=freedos-dev&m=101717593306186&w=2 |publisher=freedos-dev mailing list |access-date=2014-08-06 |url-status=live |archive-url=https://archive.today/20190427173821/https://marc.info/?l=freedos-dev&m=101717593306186&w=2 |archive-date=27 April 2019 }}</ref> <ref name="CCI_1997_HELP">{{cite book |title=CCI Multiuser DOS 7.22 GOLD Online Documentation |id=HELP.HLP |date=1997-02-10 |publisher=[[Concurrent Controls, Inc.]] (CCI)}}</ref> <ref name="DRI_1983_CPM86-PG">{{cite book |title=CP/M-86 - Operating System - Programmer's Guide |chapter=2.4.1 Numeric Constants |date=January 1983 |orig-year=1981 |edition=3 |publisher=[[Digital Research]] |location=Pacific Grove, California, USA |page=9 |url=http://www.bitsavers.org/pdf/digitalResearch/cpm-86/CPM-86_Programmers_Guide_Jan83.pdf |access-date=2020-02-27 |url-status=live |archive-url=https://web.archive.org/web/20200227225328/http://www.bitsavers.org/pdf/digitalResearch/cpm-86/CPM-86_Programmers_Guide_Jan83.pdf |archive-date=2020-02-27}} [https://web.archive.org/web/20200227132338/https://www.z80cpu.eu/mirrors/oldcomputers.dyndns.org/public/pub/manuals/cpm86pg.pdf] (1+viii+122+2 pages)</ref> }} ==External links== * [http://www.octomatics.org Octomatics] is a [[numeral system]] enabling simple visual calculation in octal. * [https://converter.app/octal-to-decimal/ Octal converter] performs bidirectional conversions between the octal and decimal system. [[Category:Binary arithmetic]] [[Category:Power-of-two numeral systems]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Anchor
(
edit
)
Template:Annotated link
(
edit
)
Template:Citation
(
edit
)
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Math
(
edit
)
Template:Mvar
(
edit
)
Template:Nowrap
(
edit
)
Template:Numeral systems
(
edit
)
Template:Numeral systems for computation
(
edit
)
Template:Overline
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)
Template:Sidebar with collapsible groups
(
edit
)
Template:Small
(
edit
)
Template:Sqrt
(
edit
)
Template:Table Numeral Systems
(
edit
)
Template:Use dmy dates
(
edit
)
Template:Val
(
edit
)
Template:Webarchive
(
edit
)