OCT2HEX Function

Converts an octal number to hexadecimal.

Category

Engineering

Available in

All versions, Microsoft 365

Returns

Hexadecimal text

Want to practice OCT2HEX in a real spreadsheet? Open a blank sheet in our Practice Sandbox and try it with live data, with the AI Excel tutor beside you. No Excel needed — just a free account.Try it free in the Sandbox

Overview

OCT2HEX converts a octal number into hexadecimal. Octal (base 8) uses the digits 0–7. Hexadecimal (base 16) uses 0–9 and then A–F for 10–15.

Negative numbers use a fixed 10-character form called two's complement: the first digit acts as the minus sign. For example −1 is 1111111111 in binary, 7777777777 in octal and FFFFFFFFFF in hex. So OCT2HEX reads a 10-character octal value starting with 4–7 as negative.

Syntax

=OCT2HEX(number, [places])

Arguments

ArgumentRequired?What it does
numberYesThe octal number to convert, as text or a number — up to 10 characters.
placesNoHow many characters to show, padding with leading zeros (e.g. 8 turns 101 into 00000101). Ignored for negative numbers.

Examples

Example 1 — Octal to hexadecimal

Each row converts the value in column A.

B2fx=OCT2HEX(A2)
AB
1OctalHex
217F
310040
47551ED
57777777533FFFFFFFF5B
=OCT2HEX(A2) Explain

Example 2 — Padded to a fixed width

Places pads the answer with leading zeros.

=OCT2HEX(100,4) Explain

Returns 0040.

Common mistakes

  • #NUM! The text isn't valid octal (for example a 2 in binary), it's longer than 10 characters, the answer doesn't fit in places, or a negative result is too big for the target base.

Notes

  • The answer is text, so it keeps leading zeros. Convert back with the matching ...2DEC function before doing maths with it.
  • Related functions: HEX2OCT, OCT2DEC, OCT2BIN.
Kyle Stott

Author

Kyle Stott

Certified Microsoft Excel Expert

Kyle has worked professionally with Microsoft Excel for over a decade and has consulted on and taught Excel best practices to over 400 companies across 30+ countries.