Re: Random number generator
[ Related Articles and Replies ] [ DelphiLand Discussion Forum ]
Posted by webmaster Guido
on January 11, 2002 at 18:08:26:
In Reply to: Random number generator posted by BeckyR on January
11, 2002 at 16:55:47:
: I want to generate random numbers but I need to set the range to start at 1000000000 instead of 0. Is there a way the starting number can be set? -------
The function Random(RANGE) returns a real number X with 0 <= X < RANGE. RANGE must be an integer, so you are limited to the largest integer that is possible in Win32 Delphi. That's 2147483648 (a bit over 2000 million).
Example: Random(50) can return 0 or 12.1231313 or 49.99999 and so on (but not 50). If RANGE is not specified, the result is a real number in the range 0 <= X < 1. If you want an integer random number, you can use Trunc() to cut off the decimal part. Example: To get a random integer in the range from 1 to 1000 you use: R := Trunc(Random(1000)) + 1; Is this the info you were looking for? If not, please give some more details about your question.
Related Articles and Replies:
[ Related Articles and Replies ] [ DelphiLand Discussion Forum ]
|