public static float NextSingle(
this Random random,
float maxValue,
FloatScale scale = FloatScale.Auto
)
<ExtensionAttribute>
Public Shared Function NextSingle (
random As Random,
maxValue As Single,
Optional scale As FloatScale = FloatScale.Auto
) As Single
public:
[ExtensionAttribute]
static float NextSingle(
Random^ random,
float maxValue,
FloatScale scale = FloatScale::Auto
)
[<ExtensionAttribute>]
static member NextSingle :
random : Random *
maxValue : float32 *
?scale : FloatScale
(* Defaults:
let _scale = defaultArg scale FloatScale.Auto
*)
-> float32
In most cases return value is less than maxValue. Return value can be equal to maxValue in very edge cases, such as using very small ranges close to the limits of Single.
If scale is Auto, then the ForceLinear option is used if maxValue is less than or equal to 65535. For larger range the ForceLogarithmic option is used.
Generating random numbers by this method on the logarithmic scale is about 3 times slower than on the linear scale.
ArgumentNullException | random is . |
ArgumentOutOfRangeException | maxValue is less than 0.0
-or-. scale is not a valid value of FloatScale. |