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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Number in Java

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
When you use a Random number, what is the range? ???(example - 0.0001-.9999)???
 
the range is the one you specify !!!!! by default it should be 0-1 but as you can set it as you want ...
 
Math.random() gives you a random number between 0 and 1.

if you want for example a number between 1 and 10, you need

Math.round(Math.random() * 10)+1; adam@aauser.com
 
On the 0-1, does it have a certain amount of numbers after the decimal point. For example, does it use .178 or would it use just .2 ???
 
here's an example number, retrieved by a simple call to Math.random():

0.22888456018069508 jared@aauser.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top