Mail Archives: djgpp/1995/06/21/18:57:40
>>>>> "Russell" == Russell Edwards <rtedw1 AT mdw023 DOT cc DOT monash DOT edu DOT au> writes:
Russell> MAXINT is defined in values.h and is the maximum value
Russell> you can store in a variable of type integer. Your
Russell> implementation of random() probably returns a random
Russell> number between 0 and MAXINT, this is so as to allow the
Russell> maximum resolution possible. Simply scale it to what you
Russell> want, eg divide it by (MAXINT/10) to get a number between
Russell> 0 an 10.
"random() % 11" is the typical way one would compute such a value. No
need to worry about MAXINT, INT_MAX, or RAND_MAX (the ANSI C upper
bound on rand()'s return value).
-Mat
- Raw text -