# A to Z of Excel Functions: the OCT2HEX Function

17 April 2023

*Welcome
back to our regular A to Z of Excel Functions blog. Today we look at the OCT2HEX function. *

** **

**The
OCT2HEX function**

This function converts an octal number (base eight) to a hexadecimal number (base 16).

The **OCT2HEX **function
employs the following syntax to operate:

**OCT2HEX(number,
[places])**

The **OCT2HEX **function has the following arguments:

**number**:**number**cannot contain more than 10 octal characters (30 bits) and that the most significant bit of**number**is the sign bit. The remaining 29 bits are magnitude bits. Negative numbers are represented using**two's complement**notation**places**:**places**is omitted,**OCT2HEX**uses the minimum number of characters necessary. The argument**places**is useful for padding the return value with leading 0s (zeroes).

**Two's
complement** is a mathematical operation on binary numbers, as well as a binary
signed number representation based on this operation. The two's complement of an **N**-bit number is defined as the
complement with respect to 2** ^{N}**;
in other words, it is the result of subtracting the number from 2

**. This is also equivalent to taking the ones' complement and then adding one, since the sum of a number and its ones' complement is all 1 bits. The two's complement of a number behaves like the negative of the original number in most arithmetic, and positive and negative numbers can coexist in a natural way.**

^{N}It should be further noted that:

- if
**number**is negative,**OCT2HEX**ignores**places**and returns a 10-character hexadecimal number - If
**number**is not a valid octal number,**OCT2HEX**returns the*#NUM!*error value - if
**OCT2HEX**requires more than**places**characters, it returns the*#NUM!*error value - if
**places**is not an integer, it is truncated - if
**places**is nonnumeric,**OCT2HEX**returns the*#VALUE!*error value - if
**places**is negative,**OCT2HEX**returns the*#NUM!*error value.

Please see my example below:

*We’ll continue our A
to Z of Excel Functions soon. Keep
checking back – there’s a new blog post every other business day.*