improve the quality of output from rand_r