Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fnumber%2Frandomint.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fdataprime%2Flanguage-reference%2Ffunctions-reference%2Fnumber%2Frandomint.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# `randomInt`

## Description

Returns a pseudorandom integer between `0` (inclusive) and an upper bound (exclusive).

Note

`randomInt` is not cryptographically secure.

## Syntax

Like many functions in DataPrime, `randomInt` supports<!-- --> [two notations](https://coralogix.com/docs/docs/dataprime/language-reference/functions-reference/.md),<!-- --> **function** and **method**. These interchangeable forms allow flexibility in how you structure expressions.

* Function notation
* Method notation

```
randomInt(upperBound: number): number
```

```
(upperBound: number).randomInt(): number
```

## Arguments

| Name         | Type     | Required | Description                                     |
| ------------ | -------- | -------- | ----------------------------------------------- |
| `upperBound` | `number` | **true** | The exclusive upper limit for the random number |

## Example

**Use case: Generate a random integer within a range**

Create a pseudorandom integer between `0` and `99` and attach it to each document.

### Example data

```
{

    "event": "login_attempt"

}
```

### Example query

* Function notation
* Method notation

```
create random_num from randomInt(100)
```

```
create random_num from 100.randomInt()
```

### Example output

```
{

    "event": "login_attempt",

    "random_num": 57

}
```
