4.5.5 Hexadecimal Numbers in Origin


Hexadecimals to Define Colors

The Hex2Dec() and Dec2Hex() Functions

Prior to Origin 2019, the worksheet and matrixsheet did not support numeric display of hexadecimal values (they could be displayed as string data only). The following functions were used, primarily in the Set Values dialog box, to convert hex strings to decimal numbers or to convert decimal numbers to hex strings.

  • The Dec2Hex() function converts a decimal number to a string representation of a hexadecimal number.
  • The Hex2Dec() function converts a string representation of a hexadecimal number, to a decimal number. Note that the Hex2Dec() function does not support the "0x" prefix and it should be removed before using the function (Hint: You can use something Origin's Mid() function to remove prefixed characters).

Numeric Support for Hex Numbers in Worksheet and Matrix

Beginning with Origin 2019, the worksheet and the matrix support display of numeric hexadecimal values. As per the IEEE 754 standard, numbers in Origin are stored in 64-bit, double-precision floating point format (Double(8)). The significand is allotted 52 bits allowing for display of up to 13 hex digits.

As with other specialized display formats, such as Date or Time, Origin will initially treat such data as text or as a base 10 number.

To display your hex values in a suitable hex format, choose a custom display format from the Column Properties dialog box (select a column, right-click and choose Properties).

Hex numbers in origin 1.png
  1. Set Format to Numeric.
  2. Set Display to Custom.
  3. Set Custom Display to one of the supported hexadecimal formats outlined in the table below. Variations include padding with zeros and display of hex characters in upper-case ("0X") or lower-case ("0x").


The following Custom Display formats are supported in 2019:

Hex Format Example Description
 %x -- 32-bit (max 8 hex digits), do not pad with zero. Lowercase "x" displays alpha hex characters as lowercase; "X" as uppercase.
 %#x -- As above but prefix with "0x".
 %#0nx  %#06x As above but pad with zero, as needed, to n hex digits.
 %#0NI64X  %#014I64X 64-bit (max 13 hex digits), pad with zero, as needed, to N hex digits. Prefix with "0X"


Origin's support for direct display of hexadecimal values also allows the user to perform bitwise operations using Origin's bitwise operators or LabTalk bit functions (bitAND, bitOR, [bitXOR], BitLShift, BitRShift).

Hex numbers in origin 2.png