Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

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


Sign up now

[java] random numbers in java...?

4: Adsense

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.


  • You cannot reply to this topic
3 replies to this topic

#1 BriarLoDeran   Members   

122
Like
Likes
Like

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();

#2 Anonypous Moster   Members   

122
Like
Likes
Like

Posted 05 February 2001 - 07:01 AM

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

#3 thuned   Members   

122
Like
Likes
Like

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


#4 BriarLoDeran   Members   

122
Like
Likes
Like

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.