?
Solved

Suggestions on generating random numbers between 0 and 1

Posted on 2000-04-26
2
Medium Priority
?
246 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 200 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

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…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

839 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