davedelong / DDMathParser

String → Number
MIT License
854 stars 153 forks source link

Implement random function to be similar to Python random.uniform() #177

Closed steve-h closed 4 years ago

steve-h commented 4 years ago

Resolves #158, resolves #160 Since python is popular now in data analysis. I chose to redo the random function to match the argument behaviour in Python.

No arguments gives random 0-1 One argument gives random 0-argument Two arguments gives random between first-second

A test in the GitHub issues tests was added with srand48 to force a seed so the test is repeatable.

It could be a breaking change if someone is using the flawed current version with arguments. I believe random() will not break. There seems to be no base level testing.

The Wiki should be appended to include the one argument behaviour. Possibly also advising anyone that uses the function that they should use srand48 to give a more random starting seed.