equal
deleted
inserted
replaced
28 |
28 |
29 procedure SetRandomSeed(Seed: shortstring); |
29 procedure SetRandomSeed(Seed: shortstring); |
30 function GetRandom: hwFloat; overload; |
30 function GetRandom: hwFloat; overload; |
31 function GetRandom(m: LongWord): LongWord; overload; |
31 function GetRandom(m: LongWord): LongWord; overload; |
32 function rndSign(num: hwFloat): hwFloat; |
32 function rndSign(num: hwFloat): hwFloat; |
33 {$IFDEF DEBUGFILE} |
|
34 procedure DumpBuffer; |
|
35 {$ENDIF} |
|
36 |
33 |
37 implementation |
34 implementation |
38 uses uMisc; |
|
39 |
35 |
40 var cirbuf: array[0..63] of Longword; |
36 var cirbuf: array[0..63] of Longword; |
41 n: byte; |
37 n: byte; |
42 |
38 |
43 function GetNext: Longword; |
39 function GetNext: Longword; |
74 GetRandom.QWordValue:= GetNext |
70 GetRandom.QWordValue:= GetNext |
75 end; |
71 end; |
76 |
72 |
77 function GetRandom(m: LongWord): LongWord; |
73 function GetRandom(m: LongWord): LongWord; |
78 begin |
74 begin |
79 TryDo((m > 0),'GetRandom(0) called! Please report this to the developers!',true); |
|
80 GetNext; |
75 GetNext; |
81 GetRandom:= GetNext mod m |
76 GetRandom:= GetNext mod m |
82 end; |
77 end; |
83 |
78 |
84 function rndSign(num: hwFloat): hwFloat; |
79 function rndSign(num: hwFloat): hwFloat; |
85 begin |
80 begin |
86 num.isNegative:= odd(GetNext); |
81 num.isNegative:= odd(GetNext); |
87 rndSign:= num |
82 rndSign:= num |
88 end; |
83 end; |
89 |
|
90 {$IFDEF DEBUGFILE} |
|
91 procedure DumpBuffer; |
|
92 var i: LongInt; |
|
93 begin |
|
94 for i:= 0 to 63 do |
|
95 AddFileLog('[' + inttostr(i) + '] = ' + inttostr(cirbuf[i])) |
|
96 end; |
|
97 {$ENDIF} |
|
98 |
84 |
99 procedure initModule; |
85 procedure initModule; |
100 begin |
86 begin |
101 n:= 54; |
87 n:= 54; |
102 FillChar(cirbuf, 64*sizeof(Longword), 0); |
88 FillChar(cirbuf, 64*sizeof(Longword), 0); |