randomize

Seeds the pseudo-random number generator with an
integer number, ensuring repeatable number patterns.

randomize(number [, algorithm]) → returns Numeric

randomize Argument Reference

number
Required

algorithm
Default: CFMX_COMPAT

The algorithm to use to generated the random number. Values:
  • CFMX_COMPAT
  • SHA1PRNG
  • IBMSecureRandom

Examples sample code invoking the randomize function


Tag Example

The following example calls the Randomize function to seed the random number generator and generates 10 random numbers.

<cfset randomize(12345)> <!--- if one was to remove this line, the random numbers are different every time ---> 
 <cfloop index="i" from="1" to="10"> 
 <cfoutput>#rand()#</cfoutput> 
 </cfloop> 

Fork me on GitHub