equal
deleted
inserted
replaced
29 *) |
29 *) |
30 interface |
30 interface |
31 uses uFloat; |
31 uses uFloat; |
32 |
32 |
33 procedure SetRandomSeed(Seed: shortstring; dropAdditionalPart: boolean); // Sets the seed that should be used for generating pseudo-random values. |
33 procedure SetRandomSeed(Seed: shortstring; dropAdditionalPart: boolean); // Sets the seed that should be used for generating pseudo-random values. |
34 function GetRandomf: hwFloat; overload; // Returns a pseudo-random hwFloat. |
34 function GetRandomf: hwFloat; // Returns a pseudo-random hwFloat. |
35 function GetRandom(m: LongWord): LongWord; overload; inline; // Returns a positive pseudo-random integer smaller than m. |
35 function GetRandom(m: LongWord): LongWord; inline; // Returns a positive pseudo-random integer smaller than m. |
36 procedure AddRandomness(r: LongWord); inline; |
36 procedure AddRandomness(r: LongWord); inline; |
37 function rndSign(num: hwFloat): hwFloat; // Returns num with a random chance of having a inverted sign. |
37 function rndSign(num: hwFloat): hwFloat; // Returns num with a random chance of having a inverted sign. |
38 |
38 |
39 |
39 |
40 implementation |
40 implementation |
90 GetNext; |
90 GetNext; |
91 GetRandomf.isNegative:= false; |
91 GetRandomf.isNegative:= false; |
92 GetRandomf.QWordValue:= GetNext |
92 GetRandomf.QWordValue:= GetNext |
93 end; |
93 end; |
94 |
94 |
95 function GetRandom(m: LongWord): LongWord; overload; inline; |
95 function GetRandom(m: LongWord): LongWord; inline; |
96 begin |
96 begin |
97 GetNext; |
97 GetNext; |
98 GetRandom:= GetNext mod m |
98 GetRandom:= GetNext mod m |
99 end; |
99 end; |
100 |
100 |