www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/06/21/18:57:40

Date: Wed, 21 Jun 95 16:08 MDT
From: mat AT ardi DOT com (Mat Hostetter)
To: rtedw1 AT mdw023 DOT cc DOT monash DOT edu DOT au (Russell Edwards)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Re: MAXINT?
Newsgroups: comp.os.msdos.djgpp
References: <3s4du6$mu3 AT oravannahka DOT Helsinki DOT FI> <3s6l9n$p18 AT harbinger DOT cc DOT monash DOT edu DOT au>

>>>>> "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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019