delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/08/07:18:37

Xref: news2.mv.net comp.lang.c:66862 comp.os.msdos.djgpp:3557
From: michel_saucier AT zone DOT ca (Michel Saucier)
Newsgroups: comp.lang.c,comp.os.msdos.djgpp
Subject: Re: Use of random
Date: Tue, 07 May 1996 23:21:20 -0400
Organization: Bell Global Solutions
Lines: 26
Message-ID: <michel_saucier-0705962321200001@news.zone.ca>
References: <4mikhp$pa5 AT frodo DOT smartlink DOT net>
NNTP-Posting-Host: zac002p16.zone.ca
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) wrote:

> 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.
> 
> I really need some serious help. Thanks.
> 
>         nicholas

Just roll your own dice:

static long LHseed=1; /* please kindly CHANGE ME */
unsigned long lehmer(void)/* Lehmer algorithm, Schrage's method to avoid
overflow */
{long hi=LHseed/127773L,lo=LHseed%127773L;
 long t=lo*16807L - hi*2836L;
 return LHseed=(t>0)?t:t+2147483647L;
}


Michel Saucier.

- Raw text -


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