AeroEng43 / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

random generator missing bits in constant #4

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The results of random are not bit-identical between the Python interpreter
and compiled code.   Only the lowest order bits are affected - the
difference is not visible with the default floating point output precision.

In lib/random.cpp, line 205

    return (((a*67108864.0)+b)*(1.0/9.00719925474e+15));

This line should be (see Python 2.5.1 source, _randommodule.c)

    return (((a*67108864.0)+b)*(1.0/9007199254740992.0));

The following program will demonstrate the issue (need to hack the
generated cpp to see the full precision).

import random

random.seed(123)
r = random.uniform(-1.0,1.0)

#print "%20.16"%r
print repr(r)

Original issue reported on code.google.com by markdew...@gmail.com on 28 Jan 2008 at 3:50

GoogleCodeExporter commented 8 years ago
great, thanks for tracking this down! I commited your change to SVN.

Original comment by mark.duf...@gmail.com on 28 Jan 2008 at 7:12