]> granicus.if.org Git - python/commitdiff
Issue 6261: Clarify behavior of random.uniform().
authorRaymond Hettinger <python@rcn.com>
Thu, 11 Jun 2009 23:18:54 +0000 (23:18 +0000)
committerRaymond Hettinger <python@rcn.com>
Thu, 11 Jun 2009 23:18:54 +0000 (23:18 +0000)
Doc/library/random.rst
Lib/random.py

index 78c3cc0bedcd8e665d80897dcf3b4c4ce2325c20..b6b0b6c4dafe6f485c315f8373c8a0c67cccf22f 100644 (file)
@@ -191,6 +191,8 @@ be found in any statistics text.
    Return a random floating point number *N* such that ``a <= N <= b`` for
    ``a <= b`` and ``b <= N <= a`` for ``b < a``.
 
+   The end-point value ``b`` may or may not be included in the range
+   depending on floating-point rounding in the equation ``a + (b-a) * random()``.
 
 .. function:: triangular(low, high, mode)
 
index 8b4c38edb1767219da53817d0b88eff550ee5333..568de88e636dacae7dc6815f0c624b2a5d27a8ac 100644 (file)
@@ -349,7 +349,7 @@ class Random(_random.Random):
 ## -------------------- uniform distribution -------------------
 
     def uniform(self, a, b):
-        """Get a random number in the range [a, b)."""
+        "Get a random number in the range [a, b) or [a, b] depending on rounding."
         return a + (b-a) * self.random()
 
 ## -------------------- triangular --------------------