Date: Mon, 26 Sep 1994 14:25:42 -0400 From: Cuthalion / Sliced Bread To: richard DOT young AT clark DOT dgim DOT doc DOT ca, roalz AT varano DOT ing DOT unico DOT it Subject: Re: Correction to (Re: Problem with rand() (fwd)) Cc: djgpp AT sun DOT soe DOT clarkson DOT edu ..roll += int(float(rand())/(RAND-MAX+1) * _sides) + 1; .. ..This still should not involve a divide since the /(RAND_MAX+1) is a ..constant and would be implemented as a multiply by 1/(RAND_MAX+1). If you're after speed, you'd probably be better off doing a integer divide, rather than a floating point multiply and truncating. And anyways, your code won't do the / in floating point. (Additionally, RAND_MAX has a _, not a -) If you want the divide to be fp, you need to do roll += int (rand()/(float)(R AND_MAX + 1)) + 1; Sorry about the wierd placement of CR's.