From 05915bf21c4a582ebe339334ff9d71aeb1628c89 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Wed, 11 Aug 2021 12:17:26 -0400 Subject: [PATCH] add an extension to Random to generate a random Int64 value --- MBS.Framework/MathExtensions.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/MBS.Framework/MathExtensions.cs b/MBS.Framework/MathExtensions.cs index e511af5..1a6a5bc 100644 --- a/MBS.Framework/MathExtensions.cs +++ b/MBS.Framework/MathExtensions.cs @@ -23,5 +23,18 @@ namespace MBS.Framework { return (x * Math.Pow(2, exp)); } + + /// + /// Returns a random between + /// and . + /// + /// The random number. + /// The instance of being extended. + /// The inclusive minimum bound of the resulting random value. + /// The exclusive maximum bound of the resulting random value. + public static long NextLong (this Random random, long minValue = 0, long maxValue = long.MaxValue) + { + return (long)((random.NextDouble() * (maxValue - minValue)) + minValue); + } } }