View Single Post
  #3 (permalink)  
Old 07-26-2007, 11:55 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,119
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
Quote below is directly from Deitel's book:

Quote:
For GNU C++, the value of RAND_MAX is 214748647; for Visual Studio, the value of RAND_MAX is 32767
Thanx a lot rpgfan3233 for the detail explanation, the equation helps a lot

Edit:

Quote:
min_value + rand() % (max_value - min_value + 1)
This equation right here, why there is "- min_value + 1" ??? I think it's kind of weird, so for example if I use min value of 2 then my maximum would be 6-1 = 5 !!!??? XD that will require me to do:

Code:
2 + rand() % 6 + 1
to keep the same maximum of "6" ??? I think that's kind of weird..

__________________
PHP Code:
System.out.println("Hello World!"); 

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by HelloWorld : 07-27-2007 at 12:00 AM.
Reply With Quote