Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


[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.

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

#1 BriarLoDeran   Members   -  Reputation: 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();

Sponsor:

#2 Anonypous Moster   Members   -  Reputation: 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   -  Reputation: 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   -  Reputation: 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.



PARTNERS