KDECore
Go to the documentation of this file.
26 class KRandomSequence::Private
81 else if (lngSeed1 == 0)
87 d->lngSeed1 = -lngSeed1;
91 static const long sMod1 = 2147483563;
92 static const long sMod2 = 2147483399;
94 void KRandomSequence::Private::draw()
96 static const long sMM1 =
sMod1 - 1;
97 static const long sA1 = 40014;
98 static const long sA2 = 40692;
99 static const long sQ1 = 53668;
100 static const long sQ2 = 52774;
101 static const long sR1 = 12211;
102 static const long sR2 = 3791;
124 lngSeed1 = sA1 * ( lngSeed1 - k*sQ1) - k*sR1;
132 shuffleArray[j] = lngSeed1;
136 lngShufflePos = shuffleArray[0];
144 lngSeed1 = sA1 * ( lngSeed1 - k*sQ1 ) - k*sR1;
153 lngSeed2 = sA2 * ( lngSeed2 - k*sQ2 ) - k*sR2;
159 j = lngShufflePos / sDiv;
160 lngShufflePos = shuffleArray[j] - lngSeed2;
161 shuffleArray[j] = lngSeed1;
163 if ( lngShufflePos < 1 )
165 lngShufflePos += sMM1;
173 if ( d->lngSeed2 < 0 )
175 d->lngShufflePos +=
sMod2;
179 if ( d->lngSeed1 < 0 )
181 d->lngSeed1 +=
sMod1;
189 static const double finalAmp = 1.0 /
double(
sMod1 );
190 static const double epsilon = 1.2E-7;
191 static const double maxRand = 1.0 - epsilon;
195 if ( ( temp = finalAmp * d->lngShufflePos ) > maxRand )
211 return max ? (((
unsigned long) d->lngShufflePos) % max) : 0;
219 return (((
unsigned long) d->lngShufflePos) & 1);
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jun 1 2013 21:52:41 by
doxygen 1.8.3.1 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.