Solved

Suggestions on generating random numbers between 0 and 1

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

759 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

17 Experts available now in Live!

Get 1:1 Help Now