I'm currently trying to implement the MRG32K3A2 algorithm for random number generation in C++. I proto-typed my program in R prior to implementing in C++, and now i'm noticing some wierd behaviour with my C++ program.
The problem boils down to the following computation:
long long m2 = 4294944443;
long long a21 = 527612;
long long a23 = -1370589;
int seed = 12345;
long long test1 = a21*seed+a23*seed
long long test2 = test1 % m2 // Modulo here
Doing this computation in for instance R or Excel gives
test1 = -10406551065
test2 = 2478282264
Doing it in C++ gives me
test1 = -10406551065
test2 = -1816662179
I'm sure there's a good reason for this, but i just don't get it. I'm programming in Visual C++ (2015) if that makes a difference.
Thanks in advance