Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TRandom {
- public:
- TRandom(int parameterA, int parameterB)
- : A_(parameterA)
- , B_(parameterB)
- , Cur_(0)
- {}
- unsigned int Random() {
- return nextRand32();
- }
- private:
- unsigned int nextRand24() {
- Cur_ = Cur_ * A_ + B_;
- return Cur_ >> 8;
- }
- unsigned int nextRand32() {
- unsigned int aa = nextRand24(), bb = nextRand24();
- return (aa << 8) ^ bb;
- }
- private:
- int A_, B_;
- unsigned int Cur_;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement