hedgewars/uRandom.pas
changeset 21 dff476dcaaa3
parent 5 0dafbd19a04c
child 22 517be8dc5b76
equal deleted inserted replaced
20:ccd2c45f043d 21:dff476dcaaa3
    53 function GetRandom: real;
    53 function GetRandom: real;
    54 var dig: TSHA1Digest;
    54 var dig: TSHA1Digest;
    55 begin
    55 begin
    56 SHA1Update(sc1, @Fill[1], Length(Fill));
    56 SHA1Update(sc1, @Fill[1], Length(Fill));
    57 sc2:= sc1;
    57 sc2:= sc1;
    58 dig:= SHA1Final(sc1);
    58 dig:= SHA1Final(sc2);
    59 Result:= frac( dig.LongWords[0]*0.0000731563977
    59 Result:= frac( dig.LongWords[0]*0.0000731563977
    60                + pi * dig.Words[6]
    60                + pi * dig.Words[6]
    61                + 0.0109070019*dig.Words[9]);
    61                + 0.0109070019*dig.Words[9])
    62 sc1:= sc2
       
    63 end;
    62 end;
    64 
    63 
    65 function  GetRandom(m: LongWord): LongWord;
    64 function  GetRandom(m: LongWord): LongWord;
    66 var dig: TSHA1Digest;
    65 var dig: TSHA1Digest;
    67 begin
    66 begin