Method NextFloat
| Improve this Doc View SourceNextFloat()
Returns a uniformly random float value in the interval [0, 1).
Declaration
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).
Declaration
public float NextFloat(float max)
Parameters
| Type | Name | Description |
|---|---|---|
| float | max | 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).
Declaration
public float NextFloat(float min, float max)
Parameters
| Type | Name | Description |
|---|---|---|
| float | min | The minimum value to generate, inclusive. |
| float | max | The maximum value to generate, exclusive. |
Returns
| Type | Description |
|---|---|
| float | 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.