Vastly different output C++ monte carlo approximation
<p>doing a C++ approximation of Pi using a random number generator, output works exactly as expected on my AMD 64 machine running Ubuntu, however on my school machine the second algorithm I've implemented is broken, and would love some insight as to why. Code is as follows:</p>

<pre><code>#ifndef RANDOMNUMBER_H_
#define RANDOMNUMBER_H_

class RandomNumber {
public:
RandomNumber() {
    x = time(NULL);
    m = pow(2, 19); //some constant value
    M = 65915 * 7915; //multiply of some simple numbers p and q
    method = 1;
}
RandomNumber(int seed) {
    x = ((seed &gt; 0) ? seed : time(NULL));
    m = pow(2, 19); //some constant value
    method = 1; //method number
    M = 6543 * 7915; //multiply of some simple numbers p and q
}
void setSeed(long int seed) {
    x = seed; //set start value
}

void chooseMethod(int method) {
    this-&gt;method = ((method &gt; 0 &amp;&amp; method &lt;= 2) ? method : 1); //choose one of     two method
}

long int linearCongruential() { //first generator, that uses linear congruential method
    long int c = 0; // some constant
    long int a = 69069; //some constant
    x = (a * x + c) % m; //solution next value
    return x;
}

long int BBS() { //algorithm Blum - Blum - Shub
    x = (long int) (pow(x, 2)) % M;
    return x;
}
double nextPoint() { //return random number in range (-1;1)
    double point;
    if (method == 1) //use first method
        point = linearCongruential() / double(m);
    else
        point = BBS() / double(M);
    return point;
}
private:
long int x; //current value
long int m; // some range for first method
long int M; //some range for second method
int method; //method number
};

#endif /* RANDOMNUMBER_H_ */
</code></pre>

<p>and test class:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;math.h&gt;
#include &lt;iomanip&gt;
#include "RandomNumber.h"
using namespace std;

int main(int argc, char* argv[]) {
cout.setf(ios::fixed);
cout.precision(6);
RandomNumber random;
random.setSeed(argc);
srand((unsigned) time(NULL));
cout &lt;&lt; "---------------------------------" &lt;&lt; endl;
cout &lt;&lt; "   Monte Carlo Pi Approximation" &lt;&lt; endl;
cout &lt;&lt; "---------------------------------" &lt;&lt; endl;
cout &lt;&lt; " Enter number of points: ";
long int k1;
cin &gt;&gt; k1;
cout &lt;&lt; "Select generator number: ";
int method;
cin &gt;&gt; method;
random.chooseMethod(method);
cout &lt;&lt; "---------------------------------" &lt;&lt; endl;
long int k2 = 0;
double sumX = 0;
double sumY = 0;
for (long int i = 0; i &lt; k1; i++) {
    double x = pow(-1, int(random.nextPoint() * 10) % 2)
            * random.nextPoint();
    double y = pow(-1, int(random.nextPoint() * 10) % 2)
            * random.nextPoint();
    sumX += x;
    sumY += y;
    if ((pow(x, 2) + pow(y, 2)) &lt;= 1)
        k2++;

}
double pi = 4 * (double(k2) / k1);
cout &lt;&lt; "M(X)  = " &lt;&lt; setw(10) &lt;&lt; sumX / k1 &lt;&lt; endl; //mathematical expectation of x
cout &lt;&lt; "M(Y)  = " &lt;&lt; setw(10) &lt;&lt; sumY / k1 &lt;&lt; endl; //mathematical expectation of y
cout &lt;&lt; endl &lt;&lt; "Pi = " &lt;&lt; pi &lt;&lt; endl &lt;&lt; endl; //approximate Pi

return 0;
}
</code></pre>

<p>The second method returns 4.000 consistently on my lab machine, yet returns a rather close approximation on my personal machine.</p>
