Solved

Suggestions on generating random numbers between 0 and 1

Posted on 2000-04-26
2
207 Views
Last Modified: 2010-04-02
Using C, I want to generate real random numbers between 0 and 1.  Any suggestions?
0
Comment
Question by:mm162
2 Comments
 
LVL 5

Accepted Solution

by:
Jan Louwerens earned 50 total points
ID: 2752723
#include <stdlib.h>
#include <time.h>

srand(time(NULL));
double randomNumber = (double)rand() / (double)RAND_MAX;
0
 
LVL 5

Expert Comment

by:CreateObject
ID: 2752724
Just a shot in the dark, but can't you use
the rand() function to do that?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now