ID EN
#Engineering

OCT2HEX

Excel Functions

Converts an octal number to its hexadecimal equivalent

Syntax

EXCEL
=OCT2HEX(number, [places])

Arguments

Parameter Description
number The octal number you want to convert.
places [optional] The number of characters to use in the result. If omitted, uses the minimum number of characters necessary.

Return Value

A hexadecimal number as text

Details

The OCT2HEX function is used to convert octal numbers (base 8) to hexadecimal numbers (base 16). This is useful when working with different number systems, especially in engineering and computer science applications. To convert the octal number 12 to hexadecimal, use the following formula: The spreadsheet below shows some basic conversions of octal numbers to hexadecimal numbers: The places argument in the OCT2HEX function specifies the minimum number of characters to use in the result. When the converted hexadecimal number has fewer characters than the value specified for places, Excel pads the result with leading zeros. This is useful when you want all results to have a consistent length. For example, to convert the octal number 12 to hexadecimal and pad the result to 3 characters, use:

Examples

Example #1 - Basic conversion

To convert the octal number 12 to hexadecimal, use the following formula:

EXCEL
=OCT2HEX(12) // returns A
Example #2 - Using the places argument

For example, to convert the octal number 12 to hexadecimal and pad the result to 3 characters, use:

EXCEL
=OCT2HEX(12, 3) // returns 00A
Example #3 - Negative octal numbers

This means the octal numbers from 4000000000 to 7777777777 are mapped to different hexadecimal numbers, because Excel uses two's complement notation t

EXCEL
=OCT2HEX(0377777777, 10) // returns 0003FFFFFF
=OCT2HEX(0400000000, 10) // returns 0004000000
=OCT2HEX(3777777777, 10) // returns 001FFFFFFF
=OCT2HEX(4000000000, 10) // returns FFE0000000

See Also

HEX2OCT OCT2BIN OCT2DEC