tohex
This page explains how to use the tohex function in APL.
Use the tohex function to convert integer or long values to hexadecimal string representation. This is helpful when you need to display numeric values in hexadecimal format, work with memory addresses, or convert identifiers to hex format for compatibility with other systems.
You typically use tohex when working with numeric identifiers, memory addresses, or when you need hexadecimal representation for debugging, logging, or system integration purposes.
Usage
Syntax
Parameters
| Name | Type | Description |
|---|---|---|
| value | int | The integer or long value to convert to hexadecimal string. |
| minLength | int | Optional. Minimum length of the resulting hex string. Default is 0. |
Returns
If conversion is successful, the result is a string value representing the hexadecimal representation. If conversion isn't successful, the result is null.
Example
Convert numeric identifiers to hexadecimal format for display or integration with systems that use hex identifiers.
Query
Output
| _time | uri | id | id_hex |
|---|---|---|---|
| Jun 24, 09:28:10 | /api/users | 12345 | 00003039 |
This example converts numeric identifiers to hexadecimal format, making them more readable and compatible with systems that use hex identifiers.
List of related functions
- toint: Converts input to integer. Use
tointfor smaller integers before converting to hex. - tostring: Converts input to string. Use
tostringfor general string conversion, andtohexspecifically for hexadecimal representation.