Page 1 of 1

RandomSeed with Maximum parameter

Posted: Wed Jul 01, 2009 4:07 am
by Mistrel
RandomSeed(Value[, Maximum])
Note: each times a program start, a new seed is generated ..
If Random() always uses the same seed then this additional parameter for RandomSeed() would be nice.

Posted: Wed Jul 01, 2009 11:44 am
by Kaeru Gaman
what would be the use of it? :?

the maximum is a parameter of Random, not of the Seed...

...

one thing I would like to see for Random() is several Rows with different Seeds...

Posted: Wed Jul 01, 2009 9:02 pm
by Mistrel
I believe RandomSeed returns a long (or integer?). The Maximum parameter would provide an alternative upper-bounds for the return value. Or maybe I'm misunderstanding the function.

Posted: Wed Jul 01, 2009 9:50 pm
by AND51
RandomSeed() ensures that you always get the same numbers, even when you restart your program.

On first program start, you get the numbers

Code: Select all

1  57  34  296  346 ...
on second start, you get the numbers

Code: Select all

1  57  34  296  346 ...
and so on. The third start gives you the same numbers again. A maximum parameter for RandomSeed() is nonsense, you can use the maximum parameter provided by Random(). This parameter is independent from RandomSeed().

Btw, Random() returns a long.

Posted: Wed Jul 01, 2009 10:51 pm
by Demivec
AND51 wrote:Btw, Random() returns a long.
Actually it's an integer.
freak, regarding returntype of Random(), wrote:Note that you only get 64bits on x64 as the returntype is integer.

Posted: Thu Jul 02, 2009 12:23 am
by Kaeru Gaman
the Seed is independent from the Range of the later called Random function.

this code:

Code: Select all

RandomSeed( 42 )
Debug Random( 4711 )
Debug Random( 4711 )
Debug Random( 10 )
Debug Random( 4711 )
always produces
866
2197
4
2483
and so it always should as a 32bit exe.

... wonder if it returns the same as a 64bit exe.

Posted: Thu Jul 02, 2009 12:27 am
by freak
> ... wonder if it returns the same as a 64bit exe.

it returns the same.

Posted: Thu Jul 02, 2009 12:29 am
by Kaeru Gaman
good to know! thanx :mrgreen:

Posted: Thu Jul 02, 2009 1:04 am
by AND51
Demivec wrote:Actually it's an integer.
Sorry, Sir. I seemingly messed it up.

Posted: Thu Jul 02, 2009 2:05 am
by Demivec
AND51 wrote:
Demivec wrote:Actually it's an integer.
Sorry, Sir. I seemingly messed it up.
:wink: No disrepect intended, Sir.

I mentioned that to clarify that you are not limited to a Long value, except when compiling for 32-bit.