{
  "id": "octal",
  "title": "Octal",
  "lang": "en",
  "source_lang": "en",
  "summary": "Octal is the base-eight positional numeral system, using digits 0–7 and representing each digit as exactly three binary bits.",
  "category": "mathematics",
  "subcategory": "algebra",
  "type": "concept",
  "aliases": [
    "Base eight",
    "Base-8 numeral system",
    "Octal numeral system"
  ],
  "generated_at": "2026-11-05",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/octal/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/octal/",
      "json": "https://aiwiki.page/zh/octal.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "Octal is a positional numeral system with base eight, using the digits 0, 1, 2, 3, 4, 5, 6, and 7. Each position represents a power of eight, so \\(10_8\\) means eight and \\(100_8\\) means sixty-four. Octal is particularly useful in computing because eight is a power of two: each octal digit corresponds exactly to three binary digits, allowing binary data to be written more compactly without changing its value."
    },
    {
      "heading": "Place value and notation",
      "text": "In an octal numeral, positions to the left of the radix point have weights \\(8^0,8^1,8^2,\\ldots\\), proceeding from right to left. Positions to the right have weights \\(8^{-1},8^{-2},8^{-3},\\ldots\\).\n\nFor example,\n\n\\[345_8 =3\\cdot8^2+4\\cdot8^1+5\\cdot8^0 =229_{10}.\\]\n\nA fractional example is\n\n\\[12.34_8 =1\\cdot8+2+\\frac{3}{8}+\\frac{4}{64} =10.4375_{10}.\\]\n\nMore generally, a finite octal numeral has the value\n\n\\[(d_n d_{n-1}\\cdots d_0.d_{-1}\\cdots d_{-m})_8 =\\sum_{k=-m}^{n}d_k8^k,\\]\n\nwhere every digit \\(d_k\\) is an integer between 0 and 7.\n\nA subscript, as in \\(345_8\\), explicitly identifies the base. In programming, other conventions are used, including the prefix 0o in languages such as Python and a leading zero in C. These are language-specific notations rather than features of octal itself.\n\nThe numerals 8 and 9 are not valid octal digits. Counting proceeds\n\n\\[0,\\ 1,\\ 2,\\ 3,\\ 4,\\ 5,\\ 6,\\ 7,\\ 10,\\ 11,\\ldots,\\ 17,\\ 20,\\ldots\\]\n\nChanging the base changes how a number is represented, not the number itself: \\(10_8\\), \\(8_{10}\\), and \\(1000_2\\) express the same value."
    },
    {
      "heading": "Conversion between octal and other bases",
      "text": "Octal and binary\n\nBecause \\(8=2^3\\), each octal digit can be replaced independently by a group of three binary digits.\n\nOctal digit | Binary group\n0 | 000\n1 | 001\n2 | 010\n3 | 011\n4 | 100\n5 | 101\n6 | 110\n7 | 111\n\nFor example,\n\n\\[753_8=111\\,101\\,011_2.\\]\n\nTo convert binary to octal, group the binary digits in threes, starting at the radix point and moving outward in both directions. If necessary, add zeros at the left end of the integer part or the right end of the fractional part:\n\n\\[1101011.1011_2 =001\\,101\\,011.101\\,100_2 =153.54_8.\\]\n\nThese added zeros do not change the value. Grouping must be aligned with the radix point; grouping from an arbitrary end can produce an incorrect result.\n\nOctal and decimal\n\nOctal-to-decimal conversion uses the weighted sum of powers of eight. An equivalent algorithm evaluates the digits from left to right, repeatedly multiplying the accumulated value by eight and adding the next digit:\n\n\\[345_8=(3\\cdot8+4)\\cdot8+5=229_{10}.\\]\n\nTo convert a nonnegative decimal integer to octal, repeatedly divide by eight and record the remainders. Reading the remainders in reverse order gives the octal representation. For \\(229_{10}\\),\n\n\\[\\begin{aligned} 229&=8\\cdot28+5,\\\\ 28&=8\\cdot3+4,\\\\ 3&=8\\cdot0+3. \\end{aligned}\\]\n\nThus \\(229_{10}=345_8\\).\n\nA fractional part is converted by repeatedly multiplying it by eight. The integer part of each product supplies the next octal digit. For example, \\(0.375\\cdot8=3\\), so \\(0.375_{10}=0.3_8\\)."
    },
    {
      "heading": "Arithmetic",
      "text": "The rules of arithmetic are unchanged, but carrying and borrowing occur at eight rather than ten.\n\nFor addition,\n\n\\[7_8+1_8=10_8, \\qquad 6_8+5_8=13_8.\\]\n\nFor example,\n\n\\[27_8+15_8=44_8.\\]\n\nIn the units column, \\(7+5\\) is twelve in decimal, written \\(14_8\\); the digit 4 is written and 1 is carried. The next column gives \\(2+1+1=4\\).\n\nIn subtraction, borrowing one unit from the next column supplies eight units in the current column:\n\n\\[30_8-7_8=21_8.\\]\n\nMultiplication and long division likewise follow ordinary positional methods, using base-eight multiplication facts. For instance,\n\n\\[7_8\\cdot7_8=61_8,\\]\n\nbecause forty-nine equals six eights plus one."
    },
    {
      "heading": "Fractions and repeating expansions",
      "text": "An octal fraction terminates precisely when its denominator, after reduction to lowest terms, is a power of two, including \\(1=2^0\\). This follows because a terminating expansion has a denominator dividing some power of eight, and \\(8^n=2^{3n}\\).\n\nExamples include\n\n\\[\\frac12=0.4_8,\\qquad \\frac14=0.2_8,\\qquad \\frac18=0.1_8,\\qquad \\frac1{16}=0.04_8.\\]\n\nA denominator containing any prime factor other than two produces a nonterminating, eventually repeating expansion. For example,\n\n\\[\\frac13=0.\\overline{25}_8.\\]\n\nAs in other integer bases, every rational number has an eventually repeating expansion, with terminating expansions regarded as repeating zeros. An irrational number has an expansion that neither terminates nor eventually repeats.\n\nTerminating values also have an alternative representation ending in infinitely many 7s:\n\n\\[1_8=0.\\overline{7}_8.\\]\n\nThe equality follows from the geometric series\n\n\\[\\sum_{k=1}^{\\infty}7\\cdot8^{-k}=1.\\]"
    },
    {
      "heading": "Historical role in computing",
      "text": "Octal was prominent in early digital computing because it provided a compact, easily translated notation for binary machine words. Machines with word lengths divisible by three were especially convenient for octal display. A 12-bit word occupies four octal digits, while a 36-bit word occupies twelve.\n\nSystems such as the PDP-8 and PDP-10 used octal extensively in technical documentation and programming practice. Octal was also prominent in PDP-11 software and documentation, despite that machine’s 16-bit word length, because important instruction fields aligned with three-bit groups.\n\nAs eight-bit bytes became standard, hexadecimal notation became more common for general-purpose memory displays and machine-code listings. Each hexadecimal digit represents four bits, so one byte occupies exactly two hexadecimal digits. Octal requires three digits for an arbitrary eight-bit byte, with the leading digit restricted to 0–3:\n\n\\[11111111_2=377_8=\\mathrm{FF}_{16}.\\]\n\nOctal nevertheless remains useful where data is naturally organized into three-bit fields."
    },
    {
      "heading": "Contemporary uses",
      "text": "File permissions\n\nA familiar use occurs in Unix and Unix-like operating systems, where ordinary file permissions are organized into three-bit groups. Within each group:\n\n- read permission has value 4;\n- write permission has value 2;\n- execute permission has value 1.\n\nTheir sum forms one octal digit. The three ordinary permission digits describe the file owner, group, and others, respectively.\n\nThus 755, interpreted as octal permission notation, represents:\n\nClass | Octal digit | Permissions\nOwner | 7 | Read, write, execute\nGroup | 5 | Read, execute\nOthers | 5 | Read, execute\n\nAn additional leading octal digit can encode the set-user-ID, set-group-ID, and sticky bits. Interpretation also depends on file type: for directories, the execute bit controls search or traversal rather than execution of a program.\n\nProgramming notation\n\nProgramming languages use different conventions for octal integer literals:\n\nLanguage | Example | Decimal value\nC | 0755 | 493\nPython 3 | 0o755 | 493\n\nSome languages also support octal escape sequences in character or string literals. In C, for example, \\101 denotes the character with numeric value \\(101_8=65_{10}\\); in an ASCII-compatible execution character set, this is A.\n\nLiteral syntax, character encoding, and the numerical base are separate matters. A leading zero does not universally indicate octal, and octal escape rules differ between languages."
    },
    {
      "heading": "Limitations and interpretation",
      "text": "Octal is less compact than hexadecimal for representing the same binary data: an octal digit encodes three bits, whereas a hexadecimal digit encodes four. It also aligns less neatly with eight-bit bytes.\n\nAmbiguous notation can cause errors. An unmarked numeral such as 100 may mean one hundred in decimal or sixty-four in octal. In languages that interpret leading-zero literals as octal, 010 has decimal value eight, while 08 is invalid as an octal literal.\n\nOctal notation alone also does not specify a stored value’s bit width, signedness, or encoding. For example, a digit sequence representing eight one-bits can describe the unsigned value 255 or, under an eight-bit two’s-complement interpretation, the signed value −1. Those interpretations come from the data format, not from base-eight notation."
    }
  ],
  "links": [
    "positional-notation",
    "binary-number",
    "integer",
    "number",
    "algorithm",
    "arithmetic",
    "fraction",
    "rational-number",
    "irrational-number",
    "geometric-series",
    "hexadecimal",
    "unix",
    "operating-system"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}