On 7 March 2013 17:55, Robert Feldt <robert.feldt / gmail.com> wrote:

>
> Random#rand and Kernel#rand are exclusive i.e. they return a value >= 0.0
> but <max if max is a Float. What if one wants a rand that is inclusive of
> the max?
>

I'm back at a computer now, and have looked up the docs for Random#rand.
Apparently in 2.0 you can simply pass an inclusive range and it will do
what you want, e.g.:  Random.rand(0.0..max)  <
http://ruby-doc.org/core-2.0/Random.html#method-i-rand>

However in 1.9, yeah, your rand_incl2 is basically what I'd do.  I
independently came up with a simplified version:
https://gist.github.com/phluid61/5107356