#define INV_RAND_MAX (1.0f / float(0x7fff))
class CRandGen
{
public:
CRandGen() : m_seed(1L) {}
CRandGen( unsigned int seed ) : m_seed(seed) {}
void Init( unsigned int seed ) { m_seed = seed; }
float RandFloat() { return float(RandInt()) * INV_RAND_MAX; }
int RandInt()
{
m_seed = m_seed * 214013L + 2531011L;
return((m_seed >> 16) & 0x7fff);
}
private:
unsigned long m_seed;
};
void test(float x, float y, float z)
{
std::cout<<x<<"\n"<<y<<"\n"<<z<<"\n";
}
int main()
{
float k=123;
CRandGen m_randGen;
test((m_randGen.RandFloat() - 0.5f)*k
,(m_randGen.RandFloat() - 0.5f)*k
,(m_randGen.RandFloat() - 0.5f)*k
);
test((m_randGen.RandFloat() - 0.5f)*k
,(m_randGen.RandFloat() - 0.5f)*k
,(m_randGen.RandFloat() - 0.5f)*k
);
test((m_randGen.RandFloat() - 0.5f)*k
,(m_randGen.RandFloat() - 0.5f)*k
,(m_randGen.RandFloat() - 0.5f)*k
);
return 0;
}
Релиз
-37.7236
-37.7236
-37.7236
-2.47562
-2.47562
-2.47562
39.7093
39.7093
39.7093
Дебуг
-37.7236
7.82099
-61.3461
-2.47562
10.4561
37.9751
39.7093
48.7034
-18.4142
Самое смешное что побочные эффекты на месте но не поле кажного вызова, а после всех.... << RSDN@Home 1.1.3 beta 1 >>