diff --git a/X10D/src/RandomExtensions/RandomExtensions.cs b/X10D/src/RandomExtensions/RandomExtensions.cs index c5eb9d4..e989b7d 100644 --- a/X10D/src/RandomExtensions/RandomExtensions.cs +++ b/X10D/src/RandomExtensions/RandomExtensions.cs @@ -131,6 +131,44 @@ namespace X10D.RandomExtensions return list[random.Next(list.Count)]; } + /// + /// Returns a random single-precision floating point number between 0 and 1. + /// + /// The instance. + /// A random single-precision floating point number between 0 and 1. + /// is . + public static float NextSingle(this Random random) + { + if (random is null) + { + throw new ArgumentNullException(nameof(random)); + } + + return random.NextSingle(0, 1); + } + + /// + /// Returns a random single-precision floating point number that is within a specified range. + /// + /// The instance. + /// The inclusive lower bound of the random number returned. + /// + /// The inclusive lower bound of the random number returned. This value must be greater than or equal to + /// . + /// + /// + /// A random single-precision floating point number between and + /// . + /// + /// is . + /// + /// is less than . + /// + public static float NextSingle(this Random random, float minValue, float maxValue) + { + return (float)random.NextDouble(minValue, maxValue); + } + /// /// Returns a new string of a specified length which is composed of specified characters. ///