OCT2HEX Function

Excel 2007+

Summary

The OCT2HEX function converts octal (base-8) numbers to hexadecimal (base-16) format, supporting both positive and negative values through two's-complement representation. Perfect for number system conversions in programming, data analysis, and digital electronics calculations.

Syntax

OCT2HEX(number, [places])

Parameters

Parameter Type Required Description
number Number Yes The octal number for conversion (up to 10 octal digits)
places Number No Desired length of result with leading zero padding

Using the OCT2HEX Function

OCT2HEX transforms octal numbers into hexadecimal representation, crucial for developers working with binary data, embedded systems, and low-level programming where different number bases are common. Use places parameter for consistent formatting in reports or fixed-width outputs.

Common OCT2HEX Examples

Basic Octal to Hex Conversion

=OCT2HEX(100,4)

Converts octal 100 to 4-digit hex: 0040

Large Negative Number

=OCT2HEX(7777777533)

Converts large octal to full 10-digit hex: FFFFFFFF5B

Simple Octal Conversion

=OCT2HEX(10)

Converts octal 10 to minimal hex: 8

Padded Output

=OCT2HEX(12,6)

Octal 12 becomes 00000C with 6-digit padding

Frequently Asked Questions

OCT2HEX ignores the places parameter and returns a 10-character hexadecimal using two's-complement notation.

Up to 10 octal characters (30 bits total including sign bit).

Invalid octal numbers return #NUM! error.

Common Errors and Solutions

#NUM!

Cause: Invalid octal number or exceeds 10 characters

Solution: Verify input contains only 0-7 digits

#NUM!

Cause: Result needs more characters than specified places

Solution: Increase places value or omit it

#VALUE!

Cause: Places argument is non-numeric

Solution: Use integer for places parameter

#NUM!

Cause: Negative places value

Solution: Places must be zero or positive integer

Notes

  • Most significant bit is sign bit, remaining 29 bits are magnitude
  • Negative results always return 10 hexadecimal characters
  • Places truncates to integer if decimal provided
  • Essential for working with file permissions, memory addresses, and binary protocols

Compatibility

Available in: Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Microsoft 365

Not available in: Excel 2003 and earlier

Content last reviewed: December 9, 2025
Update frequency: As needed
Excel versions tested: Excel 2007+