hex
Syntax
hex(X, [reverse=false])
Details
Convert data of INTEGRAL, FLOAT, COMPLEX, and BINARY types to hexadecimal and return a string. For details, see Data Types.
Note:
Similar to Python's built-in
hex
function:| Feature | DolphinDB hex |
Python hex |
|---|---|---|
| Supported Types | INTEGRAL, FLOAT, COMPLEX, and BINARY | Integer only |
| Input | Scalar/vector | Scalar only |
| Return | Complete byte representation (e.g., "00000010") | With 0x prefix (e.g., "0x10") |
| Byte Order Control | Supports reverse parameter | Not supported |
Parameters
X is an integer scalar/vector.
reverse (optional) is a Boolean value indicating whether to reverse the order of the result. The default value is false.
Returns
A scalar or vector of the STRING type.
Examples
hex(16 25)
// output: ["00000010","00000019"]
hex(16 25,true)
// output: ["10000000","19000000"]
hex(compress(1 2 3))
// output: ["00","05","ff","01","04","04","00","00","ff","ff","ff","ff","03","00","00","00","ff","ff","ff","ff","0d","00","00","80","c0","01","00","00","00","02","00","00","00","03","00","00","00"]
hex(123.456 3.1415926)
// output: ["405edd2f1a9fbe77","400921fb4d12d84a"]
