### re: How do you do random? VIEW POST

re: There is a subtle bug to consider with your code, though. If you want to guarantee an even spread among the numbers in the set of [0, 10], you'll h...

Typically don't people mean the set of numbers [0, 9] when they say they want a random int between 0 and 10? I would assume they want something out of 10 vs something out of 11

Well that is where your specification definition alarm bells should start ringing like crazy. We don't have a precise mathematical definition for ranges and sets like this in everyday language among lay folk, therefore you have to clarify what you mean. The example I gave above explicitly lays out the expectations, which the original text hadn't.

Technically speaking saying "between 0 and 10" could mean (0, 10), [0, 10], (0, 10] or [0, 10). In most conversations I've had, people tend to treat ranges as inclusive, so [0, 10] would probably be my best guess, but that's just anecdotal evidence on my part, and should always be checked.

code of conduct - report abuse