rand

Generates a pseudo-random number in the range 0 - 1.

rand([algorithm]) → returns numeric

Argument Reference

algorithm string
Default: CFMX_COMPAT

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

Links more information about rand

Examples
Sample code invoking the rand function

To generate a random number between 0 to 1

writeOutput( rand() );

To generate a random number between 0 to 1 by using CFMX_COMPAT algorithm

writeOutput( rand('CFMX_COMPAT') );

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub