title: How to implement a all inclusive random number function in Clojure?
body: <p>I was wondering how to have inclusive random numbers in Clojure. I came up with this:</p>
  
  <pre><code>(import java.util.Random)
  
  (def rnd 
    (Random.))
  (defn random-float 
    [min max rnd] 
    (+ min (* (.nextDouble rnd) (- max min))))
  </code></pre>
  
  <p>It seems that Java only has inclusive/exclusive random functions. According the documentation:</p>
  
  <blockquote>
    <p>The general contract of nextDouble is that one double value, chosen
    (approximately) uniformly from the range 0.0d (inclusive) to 1.0d
    (exclusive), is pseudorandomly generated and returned.</p>
  </blockquote>
  
  <p>Is there a way to have an inclusive/inclusive version of this function. I was thinking about increasing the maximum value with a tiny bit (0.0000000000000001). Not sure what is the impact if I do so.</p>
  
  <p>Would this work?</p>
  
  <pre><code>(random-float 0.0 1.0000000000000001 rnd)
  </code></pre>