I know they are covered in the standard library, but couldn't resist to experiment.
This could be slow due to opening the file, but still have a look....and try to benchmark if it is not obviously flawed.
PS: Taking 5 readings because, somehow in my machine, the first one is mostly coming 0;Code:int random(int low,int up) { ifstream in; in.open("/dev/urandom"); int count = 5; long num; while(count--) num+=in.get()*(count+1); in.close(); return (num%(up+1-low))+low; }



1Likes
LinkBack URL
About LinkBacks



