Xref: news2.mv.net comp.lang.c:66643 comp.os.msdos.djgpp:3486 From: bennett AT erich DOT triumf DOT ca (P.Bennett) Newsgroups: comp.lang.c,comp.os.msdos.djgpp Subject: Re: Use of random Date: 5 May 1996 22:17 PST Organization: TRIUMF: Tri-University Meson Facility Lines: 32 Distribution: world Message-ID: <5MAY199622172832@erich.triumf.ca> References: <4mikhp$pa5 AT frodo DOT smartlink DOT net> NNTP-Posting-Host: erich.triumf.ca News-Software: VAX/VMS VNEWS 1.50 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In article <4mikhp$pa5 AT frodo DOT smartlink DOT net>, nmarrone AT smartlink DOT net (Nicholas Marrone) writes... >Hullo, > To test out my radix_bit_sort function, I've been trying to generate a >list of random numbers to sort, and then sort them. The list is rather >long, 4000, and I'd like it to be ints, but I can' seem to get it! The >program compiles and runs without error, but it gives me #s far larger >than integers when I print out some results. I'm using DJGPP v2. >Here's some of the code... > Since you were storing the numbers in ints, and printing them as ints, they _can't_ be bigger than ints! Perhaps you have previously used a Borland or Microsoft compiler, where ints are 16 bits, and RAND_MAX is 32767. I expect that DJGPP has 32 bit ints, so RAND_MAX will be 2,147,483,647. (or so) If you want to restrict the numbers to 16 bits, you will have to use short ints, rather than plain ints. See the comp.lang.c FAQ (available from ftp://rtfm.mit.edu) for some discussion on restricting the range of random numbers. Peter Bennett VE7CEI | Vessels shall be deemed to be in sight Internet: bennett AT triumf DOT ca | of one another only when one can be Packet: ve7cei AT ve7kit.#vanc.bc.ca | observed visually from the other TRIUMF, Vancouver, B.C., Canada | ColRegs 3(k) GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html or: ftp://ftp-i2.informatik.rwth-aachen.de/pub/arnd/GPS/peter/index.html or: http:://vancouver-webpages.com/peter/index.html