Article View: comp.std.c
Article #4786Re: random floating point!
From: Stephen Baynes
Date: Fri, 23 Feb 1996 09:04
Date: Fri, 23 Feb 1996 09:04
21 lines
1420 bytes
1420 bytes
Daniel Williamson (D.G.Williamson@shef.ac.uk) wrote: : Does anybody know how to generate a random floating point number. I am using : top speed c, for the work and the rand() function ad defined in the ansi : standard only goes up to 32767. I suppose I could multiply it, but I'm looking : for a more elegant solution to give me the full range of +ve and -ve values. : Thanks for any help you can offer. To be precise ANSI rand() goes up to RAND_MAX which must be at least 32767. It can be more. Discussion of algorithms for floating point random numbers is outside the range of this group. I would also suggest that you read up on distributions in a book on probability and decide what distribution you want before you ask the question. -- Stephen Baynes baynes@mulsoc2.serigate.philips.nl Philips Semiconductors Ltd Southampton My views are my own. United Kingdom
Technical Details
Message-ID:
<Dn817B.90v@ukpsshp1.serigate.philips.nl>Path:
arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynesReferences:
<4ghuql$80h@bignews.shef.ac.uk>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!phcoms4.seri.philips.nl!panther!baynes From: baynes@ukpsshp1.serigate.philips.nl (Stephen Baynes) Subject: Re: random floating point! Sender: news@ukpsshp1.serigate.philips.nl (account for localnews) Message-ID: <Dn817B.90v@ukpsshp1.serigate.philips.nl> Date: Fri, 23 Feb 1996 09:04:23 GMT References: <4ghuql$80h@bignews.shef.ac.uk> Organization: Philips Semiconductors, Southampton, UK X-Newsreader: TIN [version 1.2 PL2]