# NextFloat

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

## Definition

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

## NextFloat()

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

```csharp
public float NextFloat()
```

### Returns

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

## NextFloat(float)

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

```csharp
public float NextFloat(float max)
```

### Parameters

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

### Returns

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

## NextFloat(float, float)

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

```csharp
public float NextFloat(float min, float max)
```

### Parameters

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

### Returns

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

### Remarks

The result is computed as `NextFloat() * (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`.
