File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Random number problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Random number problem" Watch "Random number problem" New topic

Random number problem

Adam Hansen

Joined: Jul 15, 2003
Posts: 2
I have looked at all the other random number questions on the forum, and have yet to find something that relates to my case. How would I generate a random number between -1 and 1?
Thanks in advance.
Joel McNary

Joined: Aug 20, 2001
Posts: 1824

Welcome to JavaRanch, Adam!
What you are looking for seems to be:

Hope this helps,

Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Adam Hansen

Joined: Jul 15, 2003
Posts: 2
Oh, my gosh. I can't believe I didn't see that before. Sometimes it is the simple math that causes the most trouble. Thanks much for the help!
I agree. Here's the link:
subject: Random number problem
jQuery in Action, 3rd edition