publish: true
date:
aliases:
- base-8
- octal
title:Like Base16 there are prefixing conventions to make it clear that a number is written in Base8 rather than Base10. However, there doesn't seem to be a standardized prefix.
Wikipedia says:
In programming languages, octal literals are typically identified with a variety of prefixes, including the digit
0, the lettersoorq, the digit–letter combination0o, or the symbol&or$. In Motorola convention, octal numbers are prefixed with@, whereas a small (or capital13(https://en.wikipedia.org/wiki/Octal#cite_note-DRI_1983_CPM86-PG-13)) lettero13(https://en.wikipedia.org/wiki/Octal#cite_note-DRI_1983_CPM86-PG-13) orq13(https://en.wikipedia.org/wiki/Octal#cite_note-DRI_1983_CPM86-PG-13) is added as a postfix following the Intel convention.14(https://en.wikipedia.org/wiki/Octal#cite_note-Kueveler-Schwoch_1996-14)[[15]](https://en.wikipedia.org/wiki/Octal#cite_note-Kueveler-Schwoch_2007-15) In Concurrent DOS, Multiuser DOS and REAL/32 as well as in DOS Plus and DR-DOS various environment variables like $CLS, $ON, $OFF, $HEADER or $FOOTER support an\nnnoctal number notation,16(https://en.wikipedia.org/wiki/Octal#cite_note-Paul_1997_NWDOSTIP-16)[[17]](https://en.wikipedia.org/wiki/Octal#cite_note-Paul_2002_CLS-17)[[18]](https://en.wikipedia.org/wiki/Octal#cite_note-CCI_1997_HELP-18) and DR-DOS DEBUG utilizes\to prefix octal numbers as well.For example, the literal 73 (base 8) might be represented as
073,o73,q73,0o73,\73,@73,&73,$73or73oin various languages.Newer languages have been abandoning the prefix
0, as decimal numbers are often represented with leading zeroes. The prefixqwas introduced to avoid the prefixobeing mistaken for a zero, while the prefix0owas introduced to avoid starting a numerical literal with an alphabetic character (likeoorq), since these might cause the literal to be confused with a variable name. The prefix0oalso follows the model set by the prefix0xused for hexadecimal literals in the C language; it is supported by Haskell,19(https://en.wikipedia.org/wiki/Octal#cite_note-19) OCaml,20(https://en.wikipedia.org/wiki/Octal#cite_note-20) Python as of version 3.0,21(https://en.wikipedia.org/wiki/Octal#cite_note-21) Raku,22(https://en.wikipedia.org/wiki/Octal#cite_note-22) Ruby,23(https://en.wikipedia.org/wiki/Octal#cite_note-23) Tcl as of version 9,24(https://en.wikipedia.org/wiki/Octal#cite_note-24) PHP as of version 8.1,25(https://en.wikipedia.org/wiki/Octal#cite_note-25) Rust26(https://en.wikipedia.org/wiki/Octal#cite_note-26) and ECMAScript as of ECMAScript 627(https://en.wikipedia.org/wiki/Octal#cite_note-27) (the prefix0originally stood for base 8 in JavaScript but could cause confusion,28(https://en.wikipedia.org/wiki/Octal#cite_note-28) therefore it has been discouraged in ECMAScript 3 and dropped in ECMAScript 529(https://en.wikipedia.org/wiki/Octal#cite_note-29)).