S
Skybuck Flying
Hi,
I have a C question.
Let's assume MT is not defined
int holdrand = 1;
int __cdecl rand (void)
{
#ifdef _MT
_ptiddata ptd = _getptd();
return( ((ptd->_holdrand = ptd->_holdrand * 214013L + 2531011L) >> 16)
&
0x7fff );
#else /* _MT */
return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
#endif /* _MT */
}
I have trouble understanding what this function returns.
My confusion is with this line:
return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
Apperently this line assigns some value to holdrand.
Something like:
holdrand becomes holdrand * blablabla etc.
But what is returned ?
I think it returns holdrand after the calculation.
But.... if that would be true... then this random number generator simply
uses the previous rand value to calculate the next one ?
Weird... I don't understand it... so that's why I ask this newsgroup =D
Bye,
Skybuck
I have a C question.
Let's assume MT is not defined
int holdrand = 1;
int __cdecl rand (void)
{
#ifdef _MT
_ptiddata ptd = _getptd();
return( ((ptd->_holdrand = ptd->_holdrand * 214013L + 2531011L) >> 16)
&
0x7fff );
#else /* _MT */
return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
#endif /* _MT */
}
I have trouble understanding what this function returns.
My confusion is with this line:
return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
Apperently this line assigns some value to holdrand.
Something like:
holdrand becomes holdrand * blablabla etc.
But what is returned ?
I think it returns holdrand after the calculation.
But.... if that would be true... then this random number generator simply
uses the previous rand value to calculate the next one ?
Weird... I don't understand it... so that's why I ask this newsgroup =D
Bye,
Skybuck