I am creating a little randomization library. One of the methods is similar to .NET's
System.Random.Next(int start, int end). The thing is, I am not sure how to decide on whether the upperp bound should be inclusive or exclusive. While .NET's
Random.Next has an exclusive upper bound, there are other frameworks and libraries that work with inclusive bound.
First there's a question of why do some library makers choose upper bound to be exclusive. IMO, from the library user's perspective, it doesn't read nice.
For example, throwing a d6 die looks like this:
var dieResult = rand.Next(1, 7);
The second argument hints either that 7 is a valid result, or that I want a random number from the range of 7 consecutive numbers starting with the number 1. None of which is true. I can't see how choosing an exclusive upper bound makes any sense.
Additionally, by being exclusive, upper bound prevents a PRNG from choosing the Int32.MaxValue which is another strange thing.
So, to summarize:
- Is there an explanation as to why did .NET devs choose upper bound to be exclusive