public static decimal NextDecimal(
this Random random,
decimal minValue,
decimal maxValue,
FloatScale scale = FloatScale.Auto
)
<ExtensionAttribute>
Public Shared Function NextDecimal (
random As Random,
minValue As Decimal,
maxValue As Decimal,
Optional scale As FloatScale = FloatScale.Auto
) As Decimal
public:
[ExtensionAttribute]
static Decimal NextDecimal(
Random^ random,
Decimal minValue,
Decimal maxValue,
FloatScale scale = FloatScale::Auto
)
[<ExtensionAttribute>]
static member NextDecimal :
random : Random *
minValue : decimal *
maxValue : decimal *
?scale : FloatScale
(* Defaults:
let _scale = defaultArg scale FloatScale.Auto
*)
-> decimal
In most cases return value is less than maxValue. Return value can be equal to maxValue in very edge cases such as when minValue is equal to maxValue or when the range is near Epsilon.
If scale is Auto, then the ForceLinear option is used if the absolute value of both minValue and maxValue are less than or equal to 65535, or when they have the same sign and the absolute value of maxValue is less than 16 times greater than the absolute value of minValue. For larger ranges the ForceLogarithmic option is used.
Generating random numbers by this method on the logarithmic scale is about 25-50 times slower than on the linear scale.
ArgumentNullException | random is . |
ArgumentOutOfRangeException | maxValue is less than minValue -or- scale is not a valid value of FloatScale. |