Re: trying to predict next rand value

From: Bill Unruh (unruh_at_string.physics.ubc.ca)
Date: 10/29/04


Date: 29 Oct 2004 16:28:49 GMT


"Skybuck Flying" <nospam@hotmail.com> writes:

]Well I figured it out myself now lol...

]This C line is nicely obfuscated... ;)

]I was wondering what was returned... holdrand after or before calculating...

]return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);

]I should read this as:

](holdrand = holdrand * 214013L + 2531011L);

]return ((holdrand >> 16) & 0x7fff);

]Bingo ! ;)

]( So it does actually two things in one line

]1. Update the holdrand variable

]2. Calculate some random value and return it ;)

Well, hardly random, but yes. In C a statement
holdrand = holdrand * 214013L + 2531011L
evaluates to the LHS. Thus your interpretation is correct.



Relevant Pages

  • Re: trying to predict next rand value
    ... Well I figured it out myself now lol... ... holdrand after or before calculating... ... > Skybuck Flying wrote: ...
    (sci.crypt)
  • Re: trying to predict next rand value
    ... Skybuck Flying wrote: ... > I am not a C programmer but to me it looks like the next time randis ... but the value of holdrand is used for the next calculation. ...
    (sci.crypt)
  • Re: What is returned ?
    ... > I have trouble understanding what this function returns. ... > Apperently this line assigns some value to holdrand. ... lol wait a second I think I understand now lol! ...
    (comp.lang.c)
  • Re: What is returned ?
    ... Skybuck Flying wrote: ... > My confusion is with this line: ... > Apperently this line assigns some value to holdrand. ... i.e. value assigned by the inner assignment operator. ...
    (comp.lang.c)