delorie.com/archives/browse.cgi | search |
Message-Id: | <200005291856.VAA13282@mailgw1.netvision.net.il> |
Date: | Mon, 29 May 2000 21:55:43 +0200 |
X-Mailer: | Emacs 20.6 (via feedmail 8.1.emacs20_6 I) and Blat ver 1.8.5b |
From: | "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il> |
To: | djgpp AT delorie DOT com |
In-reply-to: | <cs95jscumbafalh5jj0f8l6dm1u0uiq5o5@4ax.com> (message from Damian |
Yerrick on Mon, 29 May 2000 17:30:06 GMT) | |
Subject: | Re: Random numbers |
References: | <392CB951 DOT 34B432E6 AT chemistry DOT uq DOT edu DOT au> <Pine DOT SUN DOT 3 DOT 91 DOT 1000525084705 DOT 21360M-100000 AT is> <cs95jscumbafalh5jj0f8l6dm1u0uiq5o5 AT 4ax DOT com> |
Reply-To: | djgpp AT delorie DOT com |
Errors-To: | nobody AT delorie DOT com |
X-Mailing-List: | djgpp AT delorie DOT com |
X-Unsubscribes-To: | listserv AT delorie DOT com |
> From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p> > Newsgroups: comp.os.msdos.djgpp > Date: Mon, 29 May 2000 17:30:06 GMT > > int random_number = > low + (double)rand () * (high - low + 1) / RAND_MAX; > > When I do this on my target platform (386 PC), the cast to double > produces SIGNOFPE. Including emu387.dxe and emu387.bat (a script > to insert the required environment variables) fixed it. > @ECHO OFF > SET 387=N > SET EMU387=C:\PINEIGHT\EMU387.DXE > > Does this mean I have to bundle emu387.dxe with all programs that use > random numbers? The emulator is not required for the RNG, it is required for FP operations. The fragment from the FAQ uses a cast to double, to force FP computations: that's what triggers SIGNOFP. > Or can I do this to get rid of the unrandom low-order > bits? > nextPiece = (rand() >> 4) % 5; You are assuming that bits 4 to 6 are random enough. I don't think you can do that without testing.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |