The current documentation for random.uniform() reads:
Returns a random floating-point N such that a <= N <= b for a <= b and b <= N <= a for b < a .
The final value of b may or may not be included in the range, depending on the rounding of the floating point in the equation a + (ba) * random() .
Computer floating-point arithmetic is limited in accuracy and rounding errors caused by this inaccuracy can cause b not be included in the entire range of values ββused for the random value returned by uniform() .
random.random() returns a value between 0.0 (inclusive) and 1.0 (exception). There are values ββfor a and b where the calculation of the floating point sum of the sum a + (ba) * (1.0 - epsilon/2) not equal to b , but will be one minute less than b , while for other combinations the sum is b . epsilon is the minimum precision of the floating point number on your platform (see sys.float_info ) and 1.0 - epsilon/2 maximum value of random.random() can return.
If you are interested in information about why floating point arithmetic on computers is inaccurate, I can recommend the following two articles:
source share