---
title: randombool
summary: null
url: >-
  https://www.fastly.com/documentation/reference/vcl/functions/randomness/randombool
---

```
BOOL randombool(INTEGER numerator, INTEGER denominator)
```

**Available in:** all subroutines

Returns the true numerator or denominator of the time called. For example, 
`randombool(3,4)` will return `true` ¾ of the time (about 75%). This is useful
for situations like A/B testing where you want to serve one web page to 90%
of the requests and another to 10% of the requests. This example is shown below.

Formally, `randombool()` picks a pseudorandom value (0 ≤ r ≤ RAND_MAX). It then 
returns `true` if (RAND_MAX × numerator) > (r × denominator). This will 
return `true` when r/RAND_MAX &lt; numerator/denominator.

Informally, you have a bag with `denominator` balls.
`numerator` of these balls are orange. The rest are blue.
`randombool` reaches into the bag and, without looking, pulls out a ball.
It then returns true if the ball is orange, and false if it is blue.

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

This function is not prefixed with the `std.` namespace.

## Example

```vcl
if (randombool(1, 10)) {
  set req.http.X-ABTest = "A";
} else {
  set req.http.X-ABTest = "B";
}
```
