Xref: news2.mv.net comp.lang.c:66946 comp.os.msdos.djgpp:3595 From: piet AT cs DOT ruu DOT nl (Piet van Oostrum) Newsgroups: comp.lang.c,comp.os.msdos.djgpp Subject: Re: Use of random Date: 08 May 1996 16:50:43 +0200 Organization: Universiteit Utrecht, Dept. of Computer Science Lines: 25 Sender: piet AT stego DOT cs DOT ruu DOT nl Message-ID: References: <4mikhp$pa5 AT frodo DOT smartlink DOT net> <4mpqdn$9li AT moody DOT mchh DOT siemens DOT de> NNTP-Posting-Host: stego.cs.ruu.nl In-reply-to: Ronald Fischer's message of 8 May 1996 09:44:23 GMT To: Ronald Fischer DJ-Gateway: from newsgroup comp.os.msdos.djgpp >>>>> Ronald Fischer (RF) writes: RF> The only problem I see with your program is in the malloc: RF> onesp = (int *)malloc(NUM * 2) RF> Unless it happens that sizeof(int)==2, this won't allocate enough memory and RF> strange results will occur. >> but it gives me #s far larger than integers RF> This is not possible with your program. Even if rand would return a RF> long instead of an int (which it is not allowed to), you are storing it RF> into an int, and an int can't hold numbers larger than an int (did you RF> invent a bit-squeeze algorithm which stores two bits into one?). Also, RF> your printf statement prints the ints correctly as int, so I wonder how RF> you came to your strange conclusion. Apparently this person thought that integers are 16-bit things, so I guess he did mean that some numbers (or most) were bigger than 32767. If he wants to work with 16bits then he should use short rather than int, and even then he should say (short *)malloc(NUM * sizeof(short)) rather than the supposed 2. -- Piet van Oostrum URL: http://www.cs.ruu.nl/~piet