## How to use the HEX2OCT function

The HEX2OCT function converts a hexadecimal number to an octal number.

##### What is a hexadecimal number?

A hexadecimal number is a numeral system with a base of 16, for example, the decimal system uses a base of 10. This means that each digit in a hexadecimal number can have 16 possible values, from 0 to 15, however, the letters A to F are used from 10 to 15. See the hexadecimal column in the table below.

Hexadecimal numbers are often used in computers, the reason is they represent four binary digits (bits) with one hexadecimal digit. For example, the binary number 1010 is equivalent to the hexadecimal number A.

Hexadecimals make it easier to write big numbers with less digits, in other words, hexadecimals shorten binary digits considerably. For example, we can use hexadecimal to show the values of colors and MAC addresses in computers.

##### What is a octal number?

The octal system is a numeral system with a base of 8 that uses the digits 0, 1, 2, 3, 4, 5, 6 and 7. The octal system is often used in electronics because it is easy to perform a conversion between octal and binary numbers.

The following table shows the hexadecimal, octal and decimal values from 0 (zero) to 17.

Hexadecimal |
Octal |
Decimal |

0 | 0 | 0 |

1 | 1 | 1 |

2 | 2 | 2 |

3 | 3 | 3 |

4 | 4 | 4 |

5 | 5 | 5 |

6 | 6 | 6 |

7 | 7 | 7 |

8 | 10 | 8 |

9 | 11 | 9 |

A | 12 | 10 |

B | 13 | 11 |

C | 14 | 12 |

D | 15 | 13 |

E | 16 | 14 |

F | 17 | 15 |

10 | 20 | 16 |

11 | 21 | 17 |

### Table of Contents

## 1. HEX2OCT Function Syntax

HEX2OCT(*number, [places]*)

## 2. HEX2OCT Function Arguments

number |
Required. The hexadecimal number you want to convert to an octal number. The sign bit is the most significant bit. The remaining 39 bits are magnitude bits. Negative numbers are represented using two's-complement notation. |

[places] |
Optional. The number of digits to show, in other words, this creates leading zeros if not all digits are used. |

##### What is a sign bit?

The sign bit indicates whether the hexadecimal number is positive or negative, if the bit is 0 the number is positive, if the bit is 1, the number is negative.

##### What is a magnitude bit?

The remaining 39 bits are magnitude bits which represents the absolute value of the number. An absolute number is a number without the sign.

##### What is two's-complement notation?

Twoâ€™s-complement notation is used to represent negative numbers, the magnitude bits are changed from 0 to 1 and 1 to 0 and adding 1 to the result. For example:

Hexadecimal number 7FFFFFFFFF using 10 bits is 0111 1111 1111 1111 1111 1111 1111 1111 1111 1111 which is a positive decimal number.

Hexadecimal number 8FFFFFFFFF using 10 bits is 1000 1111 1111 1111 1111 1111 1111 1111 1111 1111 which is a negative decimal number.

## 3. HEX2OCT Function example

The image above shows the HEX2OCT function in cell C3, it calculates the octal number based on the specified number in cell B3.

Formula in cell C3:

The first example shows the HEX2OCT function in cell C3, the argument is specified in cell B3 which is 1 in hexadecimal and it returns 1 in octal.

Cell B4 contains F in hexadecimal which the HEX2OCT function converts to 17 in the octal numeral system shown in cell C4.

The third example converts "FFFFFFFFFF" to octal, the result is shown in cell C5 which is 7777777777 in octal.

## 4. How is the HEX2OCT Function calculated?

There is no easy way to convert from hexadecimal to octal by manually calculating the values. You can convert from hexadecimal to 4 digit binary and then put the binary digits in groups of three. Lastly, convert from three digit binary to octal, however, it is probably easier to just convert from hexadecimal to octal using the following table:

Hexadecimal |
Octal |

0 | 0 |

1 | 1 |

2 | 2 |

3 | 3 |

4 | 4 |

5 | 5 |

6 | 6 |

7 | 7 |

8 | 10 |

9 | 11 |

A | 12 |

B | 13 |

C | 14 |

D | 15 |

E | 16 |

F | 17 |

## 5. HEX2OCT Function not working

The hexadecimal argument can'tÂ contain more than 10 characters.

HEX2OCT ignores places and returns a 10-character octal number if the hexadecimal is negative.

The smallest hexadecimal value is FFE0000000 and the largest is 1FFFFFFF. Values larger or smaller than the specified range are not allowed.

HEX2OCT returns the #NUM! error value if the hexadecimal value is not valid.

HEX2OCT function returns #NUM! error value if it requires more than the places argument allows.

The places argument is truncated if not an integer.

HEX2OCT returns the #VALUE! error value if the places argument is a non-numeric value.

The HEX2OCT function returns #NUM! error if places argument is negative.

### Useful links

HEX2OCT function - Microsoft

Hex to Octal converter

Hexadecimal Number System - Cuemath

### Functions in 'Engineering' category

The HEX2OCT function function is one of many functions in the 'Engineering' category.

## How to comment

How to add a formula to your comment<code>Insert your formula here.</code>

Convert less than and larger than signsUse html character entities instead of less than and larger than signs.

< becomes < and > becomes >

How to add VBA code to your comment[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

How to add a picture to your comment:Upload picture to postimage.org or imgur

Paste image link to your comment.

Contact OscarYou can contact me through this contact form