# NextDouble

> Returns a uniformly random double value in the interval [0, 1).

## Definition

* **Type:** Method
* **Namespace:** [Unity.Mathematics](/engine/6000.7/script-reference/unity/mathematics.md)
* **Assembly:** UnityEngine.MathematicsModule

## NextDouble()

Returns a uniformly random double value in the interval \[0, 1).

```csharp
public double NextDouble()
```

### Returns

| Type                                                           | Description                                           |
| -------------------------------------------------------------- | ----------------------------------------------------- |
| [double](https://learn.microsoft.com/dotnet/api/system.double) | A uniformly random double value in the range \[0, 1). |

## NextDouble(double)

Returns a uniformly random double value in the interval \[0, max).

```csharp
public double NextDouble(double max)
```

### Parameters

**** (\[double]\(https\://learn.microsoft.com/dotnet/api/system.double)): The maximum value to generate, exclusive.

### Returns

| Type                                                           | Description                                             |
| -------------------------------------------------------------- | ------------------------------------------------------- |
| [double](https://learn.microsoft.com/dotnet/api/system.double) | A uniformly random double value in the range \[0, max). |

## NextDouble(double, double)

Returns a uniformly random double value in the interval \[min, max).

```csharp
public double NextDouble(double min, double max)
```

### Parameters

**** (\[double]\(https\://learn.microsoft.com/dotnet/api/system.double)): The minimum value to generate, inclusive.**** (\[double]\(https\://learn.microsoft.com/dotnet/api/system.double)): The maximum value to generate, exclusive.

### Returns

| Type                                                           | Description                                               |
| -------------------------------------------------------------- | --------------------------------------------------------- |
| [double](https://learn.microsoft.com/dotnet/api/system.double) | A uniformly random double value in the range \[min, max). |

### Remarks

The result is computed as `NextDouble() * (max - min) + min`, so floating-point rounding can in rare cases return a value equal to `max` rather than strictly less than it. Clamp the result if you require a value strictly less than `max`.
