How reliable is the Random function in Delphi

前端 未结 9 1357
遥遥无期
遥遥无期 2020-12-30 06:53

I am writing a program which write statistical tests in Delphi (must be Delphi) and I\'ve heard that the Random functionality is somewhat odd. You have to call randomize to

9条回答
  •  天命终不由人
    2020-12-30 07:05

    If they didn't change the implementation since I analyzed it(Delphi 4 IIRC), the Delphi PRNG is implemented like this:

    Randseed:=int32(Randseed*$08088405)+1
    result:=Randseed*Range shr 32
    

    (Pseudocode/assume the multiplications are on arbitrarily large integers)

提交回复
热议问题