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
(section)
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!
==={{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]] -->
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)