View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# [java] random numbers in java...?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

3 replies to this topic

### #1BriarLoDeran  Members

Posted 05 February 2001 - 06:25 AM

I am new to java. What is the java equivolent to rand() in C/C++? Thanks, Briar->LoDeran();

### #2Anonypous Moster  Members

Posted 05 February 2001 - 07:01 AM

Math.random() returns a double in range 0.0-1.0

### #3thuned  Members

Posted 05 February 2001 - 12:51 PM

actually, i don''t think it reaches 1.0.
for example, if u want a random number between 1 and 5, you would do
Math.random()*5 + 1

min is 0.0*5 + 1 = 1
max is .999*5 + 1 = 5.995

### #4BriarLoDeran  Members

Posted 06 February 2001 - 02:18 PM

Thanks a lot guys. It was so simply I feel stupid, but often times feeling stupid is part of learning...! ...right?!?

Briar->LoDeran();

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.