The OCT2DEC function in Google Sheets converts a signed octal number (base 8) into its decimal (base 10) equivalent. Its syntax is OCT2DEC(signed_octal_number), and it works directly in any cell, for example =OCT2DEC("17") returns 15.
What Is an Octal Number?
Octal is a base-8 number system that uses digits 0 through 7. Each position represents a power of 8, so the octal number 17 means (1 × 8¹) + (7 × 8⁰) = 8 + 7 = 15 in decimal. Octal was more common in early computing because each octal digit maps to exactly three binary bits (e.g., binary 111 is octal 7). Today, you might still see octal in Unix file permissions (like chmod 755) or in certain programming contexts.
How OCT2DEC Works in Google Sheets
The function accepts a single argument, signed_octal_number. It interprets that argument as a signed octal number, meaning it can represent both positive and negative values using a fixed-width two’s complement style. Google Sheets treats the input as a 10-digit octal number (30 bits) for sign handling.
- Positive numbers: If the most significant digit is 0–3, the value is positive. Example:
=OCT2DEC("10")returns8. - Negative numbers: If the most significant digit is 4–7, the number is treated as negative (two’s complement). For example,
=OCT2DEC("7777777777")returns-1because that octal pattern represents all bits set in a 30-bit signed integer.
You can enter the octal number as a string with quotes (as above) or as a cell reference. If you enter a plain number without quotes, Google Sheets may interpret it as decimal first, so it’s safer to use text.
Practical Examples and Formula Use
Suppose you have octal values in cells A2:A5. To convert them all to decimal, you would enter =OCT2DEC(A2) in B2 and drag down. Here’s a small worked example:
- A2 = “5” →
=OCT2DEC(A2)returns 5 - A3 = “12” → returns 10 (1×8 + 2)
- A4 = “100” → returns 64 (1×64)
- A5 = “777” → returns 511 (7×64 + 7×8 + 7)
You can also combine it with other functions. For instance, to convert a binary number to octal and then to decimal, you could use =OCT2DEC(BIN2OCT("1010")) which first converts binary 1010 to octal 12, then to decimal 10.
Common Errors and How to Fix Them
Several issues can arise when using OCT2DEC:
- #NUM! error: This appears if the input is not a valid octal number (contains digits 8 or 9) or if the result is outside the allowed range. For example,
=OCT2DEC("8")gives #NUM!. - #VALUE! error: This occurs if the argument is not a number or a reference to a cell containing text that isn’t numeric. For example,
=OCT2DEC("hello"). - Wrong sign: If you expect a positive number but get a negative, check the most significant digit. An octal string starting with 4–7 is treated as negative. To force a positive interpretation, you might need to pad with leading zeros, but that still won’t work if the number exceeds the 30-bit limit.
If you need to convert a decimal number to octal instead, use the DEC2OCT function.
OCT2DEC vs. DEC2OCT and Other Conversions
Google Sheets includes a full set of base conversion functions under the Engineering category. The most relevant are:
DEC2OCT(number, [places])– converts decimal to octal.BIN2OCT(number, [places])– converts binary to octal.OCT2BIN(number, [places])– converts octal to binary.OCT2HEX(number, [places])– converts octal to hexadecimal.
These functions all follow the same signed-number convention. The optional places argument pads the result with leading zeros to a specified length. For example, =DEC2OCT(10, 4) returns 0012.
Using OCT2DEC in Real-World Scenarios
You’re most likely to need OCT2DEC when working with legacy data, Unix permissions, or network configuration files that store values in octal. For instance, if you have a list of file permission codes like 644 and 755, you could convert them to decimal to understand the numeric equivalent, though those are already decimal representations of the octal digits. More commonly, you might receive a dataset with octal-encoded integers from an old system and need to analyze them in decimal.
If you’re working with binary data, you might also use OCT2DEC in combination with HEX2OCT or BIN2OCT to bridge between bases. Always remember that the input is treated as a signed 30-bit number, which limits the range to about -536,870,912 to 536,870,911 in decimal.
Frequently Asked Questions
How do I convert a negative octal number to decimal in Google Sheets?
Simply use OCT2DEC with the octal string. If the octal number has a leading digit of 4–7, the function automatically returns the negative decimal equivalent. For example, =OCT2DEC("7777777777") returns -1.
Why does OCT2DEC return #NUM! for some inputs?
#NUM! appears when the input contains digits 8 or 9, which are invalid in octal, or when the result is outside the supported range. Make sure your octal string only uses digits 0–7 and is not longer than 10 digits.
Can I use OCT2DEC with a cell that contains a number instead of text?
Yes, but be cautious. If the cell contains the number 17, Google Sheets may interpret it as decimal 17, not octal. To avoid confusion, format the cell as text or enter the octal with quotes, like “17”.
Is there a way to convert an octal number to decimal without using a formula?
You can use the Convert menu? Actually, no. Google Sheets doesn’t have a built-in menu for base conversion. You must use a formula like OCT2DEC or manually compute using powers of 8.
What is the difference between OCT2DEC and DEC2OCT?
OCT2DEC converts from octal to decimal, while DEC2OCT does the reverse. Both are part of the Engineering functions and handle signed numbers similarly. Use the one that matches the direction you need.
Final Tips for Accurate Conversion
Always double-check that your input is truly octal. A common mistake is to enter a decimal number that looks like octal (e.g., 10) without quotes, which gets misinterpreted. Also, remember that the function is case-insensitive for letters, but octal only uses digits, so no letters are involved. If you’re working with large numbers, verify the result against a known calculator to ensure you’re within the signed range. For most everyday spreadsheet tasks, OCT2DEC is straightforward and reliable.
Related
- IMLOG10 in Google Sheets: Complex Log Base 10
- Google Sheets SUMIF Blank: How to Sum Empty Cells
- Upwork Data Entry Jobs: Real Pay, Skills, and Pitfalls
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel Page Break Dotted Lines: Meaning and Fixes ExplainedExcel page break dotted lines mark where the worksheet is expected to split across printed pages. To hide…
- Hide Column in Tableau: Steps and TipsTo hide a column in Tableau, right-click the column header in the view and select Hide. This removes…
- Excel Solver Parameters: How to Set Them CorrectlyExcel Solver parameters tell the Solver add-in what result to optimize, which cells it may change, and what…
- Excel Slicer: How to Hide Blank ItemsYes, you can hide blank entries from an Excel slicer in some cases: select the slicer, open Slicer…
- DMC Thread Inventory Spreadsheet: What to TrackYes. A DMC thread inventory spreadsheet can be a simple Excel workbook with one row per color and…
- How to Present PowerPoint and See Your Speaker NotesTo present PowerPoint while keeping your notes visible, connect your computer to a second screen, set the displays…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.