Engineering function

OCT2HEX function

Converts an octal number to hexadecimal text, for example "100" to "40". Negative octal values give 10-digit hex results.

Available in Excel 2007 and later (Excel 2003 needed the Analysis ToolPak add-in), Microsoft 365, Excel for the web, Excel for Mac

Excel 2007 and laterWorks in Google Sheets

Syntax

OCT2HEX(number, [places])
ArgumentWhat it means
numberRequiredThe octal number to convert, as text or a number. At most 10 characters (30 bits): -536,870,912 to 536,870,911. A 10-character value whose first digit is the highest one is read as negative (two's complement).
placesOptionalMinimum number of characters to return, padded with leading zeros. Ignored when the result is negative.

Returns: Text containing the hexadecimal digits.

How OCT2HEX works

OCT2HEX converts from base 8 to base 16 in one step. It is useful when old documentation lists values in octal but newer tools expect hex, for example when migrating legacy device codes.

Inputs can have up to 10 octal digits. A 10-digit input starting with 4–7 is negative and the result is then 10 hex digits in two's complement (starting FFFFFFFF…). Positive results can be padded with places.

Examples

1Octal to hex

B2fx=OCT2HEX(A2, 4)
AB
1Octal
21000040

Result: 0040

Octal 100 is 64 in decimal, which is 40 in hex. places = 4 pads it to 0040.

2Negative octal value

B2fx=OCT2HEX(A2)
AB
1Octal
27777777533FFFFFFFF5B

Result: FFFFFFFF5B

The input is -165 in octal two's complement; the hex equivalent of -165 in 40 bits is FFFFFFFF5B.

⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 13 KB

Common errors and how to fix them

ErrorWhy it happensFix
#NUM!The input is not valid octal, is longer than 10 characters, or places is too small or negative.Check for digits 8 and 9 and increase places.

Tips

  • The result is upper-case text. Use HEX2DEC if you need the number itself.

Google Sheets

OCT2HEX also exists in Google Sheets and works the same way for everyday use, so the examples above work there too.

OCT2HEX in other languages

In a non-English version of Excel the function has a local name. Excel translates formulas automatically when a file is opened in another language.

LanguageFunction name
DanishOKT.TIL.HEX
DutchOCT.N.HEX
FinnishOKTHEKSA
FrenchOCTHEX
GermanOKTINHEX
HungarianOKT.HEX
ItalianOCT.HEX
Norwegian (Bokmål)OKTTILHEKS
PolishÓSM.NA.SZESN
Portuguese (Brazil)OCTAHEX
Portuguese (Portugal)OCTAHEX
RussianВОСЬМ.В.ШЕСТН
SpanishOCT.A.HEX
SwedishOKT.TILL.HEX