From: Charles Brasted Subject: Re: random() To: djgpp AT delorie DOT com Date: Thu, 28 Dec 1995 22:30:01 +1030 (CST) > > > On Sun, 24 Dec 1995, Geoffrey Wong wrote: > > > I noticed that drand48() doesn't work under DOS, so I used random() > > instead but my problem is that random() keep giving me Floating point > > exceptions. > > What do I need to do to get th code complied under DOS. > > Also random() give the result zero under Unix, is that right? > > Please post the code fragment where you call random() and the stack dump > message printed when the floating point exception hits. I think there > might be something wrong with the way you use random(), because it should > work both under DOS and Unix, and it surely should return a non-zero > result. > Actually, as an interesting digression, the simple random number generator on my unix compiler [randx = (A*randx + B) % C where A,B,C are numbers which presently escape me] did not work on DJ's compiler. The reason? My Unix machine is 16 bit and my PC is not (slaps forehead several times). There is a similar equation which can be used (there are enormous problems with simple generators, but for many situations they will suffice), if anyone wants it, email me direct (I suspect most users would have their own sophisticated set up). Oh, and I'd be interested to see Geoff's code as well. Charles.