Converts a octal number to hexadecimal.
OCT2HEX(octalnumber, numdigits)
returns text representing a hexadecimal number, given octalnumber, which may be text, or a number containing only digits 0 to 7 (thus the number appears to be octal although it is not).
octalnumber may have up to ten digit in twos complement representation; positive numbers are 0 to 3777777777 (representing 0 to 229-1 decimal) and negative numbers 7777777777 to 4000000000 (representing -1 to -229 decimal).
numdigits is an optional number specifying the number of digits to return.
If octalnumber is negative, OCT2HEX returns ten octal digits, representing the octal number in twos complement form.
OCT2HEX("35")
returns 1D as text.
OCT2HEX(35)
returns 1D as text. The number 35 is read as octal, even though it is not.
OCT2HEX("35", 4)
returns 001D as text. OCT2HEX adds leading zeroes to make 4 digits.
OCT2HEX("7777777776")
returns FFFFFFFFFE as text (twos complement representation of decimal -2).
Computer System Configuration
The OCT2HEX function is particularly useful in fields like computer science and engineering when dealing with different number systems. A common application is in system configuration, especially when working with permissions, memory addresses, or hardware settings.
Let's imagine you're a system administrator configuring access permissions on a legacy Unix-based system. These permissions are often represented using octal numbers, which are compact and easy for humans to read and work with. However, for certain low-level system calls or when viewing log files, it's more convenient or necessary to see these values in hexadecimal format, which is a standard for many programming languages and hardware interfaces.
You have a list of file permissions in octal format that you need to convert to hexadecimal for a new system script. The octal numbers represent a combination of read, write, and execute permissions for the owner, group, and others.
Here's how you can use the OCT2HEX function to perform this conversion.
Table: Converting Octal File Permissions to Hexadecimal
File Name | Octal Permission | Formula | Hexadecimal Permission | Notes | ||
|---|---|---|---|---|---|---|
A | B | C | D | E | ||
1 | script.sh | 755 | OCT2HEX(B1) | 1ED | Common permissions for an executable script. | |
2 | data.txt | 644 | OCT2HEX(B2) | 1ED | Read-only for others, read-write for owner. | |
3 | config.ini | 600 | OCT2HEX(B3) | 180 | Owner can read and write; no access for anyone else. | |
4 | temp_file | 777 | OCT2HEX(B4) | 1FF | Full read, write, and execute permissions for everyone. | |
5 | private.key | 400 | OCT2HEX(B5) | 100 | Owner can read only; no access for anyone else. |
In this example, the OCT2HEX function takes the octal number in the "Octal Permission" column and returns its hexadecimal equivalent, which you can then use in your system script or for analysis. This simple conversion saves you from having to do manual calculations and reduces the risk of errors.
PRODUCT & FEATURES
RESOURCES
Terms | Privacy | Spam Policy
© 2026 Zapof