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

```
INTEGER randomint(INTEGER from, INTEGER to)
```

**Available in:** all subroutines

Returns a random integer value between `from` and `to`, inclusive.

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

Even though integer values in VCL are typically 64-bit signed integers,
this VCL function only accepts `from` and `to`, which are signed 32-bit integers.
The range of valid values for `from` and `to` is therefore
−(2<sup>31</sup>) to 2<sup>31</sup> − 1 inclusive.
That is, the minimum and maximum values are -2147483648 and 2147483647
respectively, or -0x80000000 and 0x7FFFFFFF in hexadecimal.

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

## Example

```vcl
if (randomint(0, 99) < 5) {
  set req.http.X-ABTest = "A";
} else {
  set req.http.X-ABTest = "B";
}
if (randomint(-1, 0) == -1) {
  set req.http.X-ABTest = "A";
} else {
  set req.http.X-ABTest = "B";
}
```
