NextFloat
Returns a uniformly random float value in the interval [0, 1).
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Method
- Namespace: Unity.Mathematics
- Assembly: UnityEngine.MathematicsModule
NextFloat()
Returns a uniformly random float value in the interval [0, 1).
public float NextFloat()
Returns
Type | Description |
|---|---|
| float | A uniformly random float value in the range [0, 1). |
NextFloat(float)
Returns a uniformly random float value in the interval [0, max).
public float NextFloat(float max)
Parameters
The maximum value to generate, exclusive.
Returns
Type | Description |
|---|---|
| float | A uniformly random float value in the range [0, max). |
NextFloat(float, float)
Returns a uniformly random float value in the interval [min, max).
public float NextFloat(float min, float max)
Parameters
Returns
Type | Description |
|---|---|
| float | A uniformly random float value in the range [min, max). |
Remarks
The result is computed as , so floating-point rounding can in rare cases return a value equal to rather than strictly less than it. Clamp the result if you require a value strictly less than .
NextFloat() * (max - min) + minmaxmax