Solved

Suggestions on generating random numbers between 0 and 1

Posted on 2000-04-26
2
214 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
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 how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

813 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

15 Experts available now in Live!

Get 1:1 Help Now