make sure rand() returns values only up to RAND_MAX; #1855