Overview
Therandom_int macro generates a random 6-digit integer by concatenating six randomly selected digits. This is useful for creating pseudo-random numbers for IDs, cache busting, or other purposes requiring random numeric values.
Syntax
Parameters
This macro takes no parameters.Return Value
Returns a 6-digit integer with values ranging from000000 to 999999.
Example output: 482739
Usage
Import the Macro
Basic Example
537281 (value will vary)
Common Use Cases
Multiple Random Numbers
Conditional Logic Based on Random Value
Implementation Details
The macro generates a 6-digit number by:- Looping 6 times (indices 0-5)
- On each iteration, randomly selecting a digit from 0-9 using HubL’s
randomfilter - Concatenating all digits to form a 6-digit number
Leading zeros are possible (e.g.,
000123, 042857). If you need numbers guaranteed to be 6 digits when used mathematically, consider adding validation or using a different approach.Related Macros
- unique_id - Generates a unique identifier using multiple random integers
Distribution
The random distribution is approximately uniform across all digits (0-9), resulting in:- Range:
000000to999999 - Total possible values: 1,000,000
- Each digit position has equal probability for each digit (0-9)