diff options
author | Raymond Hettinger <python@rcn.com> | 2009-06-11 23:14:53 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2009-06-11 23:14:53 (GMT) |
commit | 2c0cdca56447d33e714a010459ee4318fff89c66 (patch) | |
tree | f1b5910a50a1eeca3c18de9ccba48c5dc7548515 | |
parent | 4efb5d0b82becae8435057be59e20044f22130df (diff) | |
download | cpython-2c0cdca56447d33e714a010459ee4318fff89c66.zip cpython-2c0cdca56447d33e714a010459ee4318fff89c66.tar.gz cpython-2c0cdca56447d33e714a010459ee4318fff89c66.tar.bz2 |
Issue 6261: Clarify behavior of random.uniform().
-rw-r--r-- | Doc/library/random.rst | 2 | ||||
-rw-r--r-- | Lib/random.py | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 78c3cc0..b6b0b6c 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -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) diff --git a/Lib/random.py b/Lib/random.py index 8b4c38e..568de88 100644 --- a/Lib/random.py +++ b/Lib/random.py @@ -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 -------------------- |