diff --git a/X10D/src/RandomExtensions/RandomExtensions.cs b/X10D/src/RandomExtensions/RandomExtensions.cs index 4d7eaa0..7651991 100644 --- a/X10D/src/RandomExtensions/RandomExtensions.cs +++ b/X10D/src/RandomExtensions/RandomExtensions.cs @@ -54,6 +54,35 @@ namespace X10D.RandomExtensions return random.NextDouble() >= 0.5; } + /// + /// Returns a random double-precision floating point number that is within a specified range. + /// + /// The instance. + /// The inclusive lower bound of the random number returned. + /// + /// The inclusive upper bound of the random number returned. This value must be greater than or equal to + /// . + /// + /// + /// A random double-precision floating point number between and + /// . + /// + /// is . + /// is less than . + public static double NextDouble(this Random random, double minValue, double maxValue) + { + if (random is null) + { + throw new ArgumentNullException(nameof(random)); + } + + if (maxValue < minValue) + { + throw new ArgumentException("maximum must be greater than or equal to minimum."); + } + + return random.NextDouble() * (maxValue - minValue) + minValue; + } /// /// Returns a random element from using the instance.