We've been making changes to how we organize and display our docs. Our work isn't done but we'd love your feedback.

randombool()

Returns a random, boolean value. The result is true when, given a pseudorandom number r, (RAND_MAX * numerator) > (r * denominator).

This does not use secure random numbers and should not be used for cryptographic purposes.

This function is not prefixed with the std. namespace.

Format

BOOL
randombool(INTEGER numerator, INTEGER denominator)

Examples

1
2
3
4
5
if (randombool(1, 10)) {
  set req.http.X-ABTest = "A";
} else {
  set req.http.X-ABTest = "B";
}