Hunt for rand and srand implementations ;)
From: Skybuck Flying (nospam_at_hotmail.com)
Date: 10/28/04
- Next message: Skybuck Flying: "Re: Hunt for rand and srand implementations ;)"
- Previous message: Skybuck Flying: "trying to predict next rand value"
- Next in thread: Skybuck Flying: "Re: Hunt for rand and srand implementations ;)"
- Maybe reply: Skybuck Flying: "Re: Hunt for rand and srand implementations ;)"
- Reply: Bob Harris: "Re: Hunt for rand and srand implementations ;)"
- Maybe reply: Skybuck Flying: "Re: Hunt for rand and srand implementations ;)"
- Reply: Randy Howard: "Re: Hunt for rand and srand implementations ;)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 28 Oct 2004 23:16:27 +0200
Hello,
This search for random implementations is starting to get interesting... so
time for a bit more professional approach ;)
If you know any implementations for srand() and rand() for a platform you
could add it to this (newsgroup) thread in this style:
Then we get a whole lot of srand and rand implementations =D
// visual c cpp 6 srand and rand
// implementation unknown...
void visual_c_cpp_6_srand( unsigned int seed )
{
srand( seed );
}
int visual_c_cpp_6_rand(void)
{
return rand();
}
// IBM AIX srand and rand implementation occurding to:
//
http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.aix.doc/libs/basetrf2/rand.htm
static unsigned int IBM_AIX_next = 1;
int IBM_AIX_rand(void)
{
IBM_AIX_next = IBM_AIX_next * 1103515245 + 12345;
return ((IBM_AIX_next >>16) & 32767);
}
void IBM_AIX_srand(unsigned int Seed)
{
IBM_AIX_next = Seed;
}
int main()
{
int seed;
// use same seed for all srand functions to find same implementations ;)
etc ;)
seed = 12345;
// visual c/c++ 6.0 srand and rand:
printf("visual c/c++ 6.0 \n" );
srand( seed );
printf("rand1: %d \n", rand() );
printf("rand2: %d \n", rand() );
printf("rand3: %d \n", rand() );
// visual c/c++ 6.0 rand output for srand seed 12345
// rand1: 7584
// rand2: 19164
// rand3: 25795
// IBM AIX srand and rand:
printf("IBM AIX \n" );
srand( seed );
printf("rand1: %d \n", IBM_AIX_rand() );
printf("rand2: %d \n", IBM_AIX_rand() );
printf("rand3: %d \n", IBM_AIX_rand() );
// IBM AIX rand output for srand seed 12345
// rand1: 16838
// rand2: 5758
// rand3: 10113
return 0;
}
Bye,
Skybuck.
- Next message: Skybuck Flying: "Re: Hunt for rand and srand implementations ;)"
- Previous message: Skybuck Flying: "trying to predict next rand value"
- Next in thread: Skybuck Flying: "Re: Hunt for rand and srand implementations ;)"
- Maybe reply: Skybuck Flying: "Re: Hunt for rand and srand implementations ;)"
- Reply: Bob Harris: "Re: Hunt for rand and srand implementations ;)"
- Maybe reply: Skybuck Flying: "Re: Hunt for rand and srand implementations ;)"
- Reply: Randy Howard: "Re: Hunt for rand and srand implementations ;)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|
|