Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Numbers

Status
Not open for further replies.

NipsMG

Programmer
Dec 27, 2000
215
US
I'm sorry, I know this is a REALLY elementary post, but I've only recently (as in the past few days), started learning C++. (I've been a Basic/VB programmer my whole life).

I got a book on C++ and have been learning, as well as following OpenGL tutorials.. The syntax is the only major issue, however I'm not having too much of a problem following it..

What' I'm looking for is a Random Number function, that can give me a float value between 0 and 1. The only random function shown in the book I have, rand(), seems only to give integers and does not allow for the specification of a range.

I appreciate your help in advance.

Thanks!
--NipsMG
 
hmm..

Code:
float f;
f = (rand() % 11) * 0.1f;

seems to work. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top