-
Notifications
You must be signed in to change notification settings - Fork 173
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
import random
def test_seed():
print(random.random())
print(random.random())
test_seed()This gives in LPython:
$ lpython c.py
7.82636925942561089e-06
1.31537788143166245e-01
$ ./c.out
7.82636925942561089e-06
1.31537788143166245e-01
$ ./c.out
7.82636925942561089e-06
1.31537788143166245e-01
$ ./c.out
7.82636925942561089e-06
1.31537788143166245e-01
$ ./c.out
7.82636925942561089e-06
1.31537788143166245e-01Compared to CPython:
$ python c.py
0.1609877035160111
0.6090058937273372
$ python c.py
0.8816157116238759
0.7730379472615071
$ python c.py
0.7851910501722984
0.926580268293728
$ python c.py
0.23538691043891513
0.3621541015534898
$ python c.py
0.09200106922546647
0.8737898472693616The random number generator itself works well, but the seed is always the same. We need to initialize the seed using system clock at the beginning of the program.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working