Solved

Suggestions on generating random numbers between 0 and 1

Posted on 2000-04-26
2
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 clear a vector as well as how to detect empty vectors in C++.

729 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