This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hailperin
Recipients hailperin
Date 2009-01-18.00:03:15
SpamBayes Score 6.1662536e-07
Marked as misclassified No
Message-id <1232236998.05.0.906555449746.issue4979@psf.upfronthosting.co.za>
In-reply-to
Content
The documentation for random.uniform says that random.uniform(a,b) 
should return a number strictly less than b, assuming a<b.  (The result 
should be strictly less than a if a>b.)  Thus both of the following 
expressions should always evaluate to False:

a<b and b in [random.uniform(a,b) for i in range(20)]
a<b and b in [random.uniform(b,a) for i in range(20)]

Yet both of them evaluate to True (except, presumably, one time in a 
million) after doing the following assignments:

a = 1.0
b = 1.0 + 2.0**-52

Other values of a and b also exist for which random.uniform will 
sometimes return its upper limit.  (For example, the -52 can be 
increased to -51, -50, etc., with correspondingly less frequent 
violations of the spec.)

Because this is a case where the code is violating an explicit 
specification in the documentation, I'm reporting it as a behavior bug.  
But perhaps the behavior is as intended and the documentation is at 
fault.  For that reason, I'm also emailing docs@python.org.
 
The documentation would in any case need a little touching up, in that 
it has a self-contradictory specification for the case where a=b.  There 
is no value N for which a<=N<b, given a=b.  That minor touch-up could be 
combined with allowing the behavior described in this bug report, if 
that behavior is in fact desired.
History
Date User Action Args
2009-01-18 00:03:18hailperinsetrecipients: + hailperin
2009-01-18 00:03:18hailperinsetmessageid: <1232236998.05.0.906555449746.issue4979@psf.upfronthosting.co.za>
2009-01-18 00:03:17hailperinlinkissue4979 messages
2009-01-18 00:03:15hailperincreate