B
buddyletts
Below is some test code:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double P = -1943.6650940829325;
double R = 3.6683591763449312;
double Rc = 3.5964170000000002;
double a = exp(-pow(R,2)/pow(Rc,2));
double b = a*P;
double c = P*a;
double d = P*exp(-pow(R,2)/pow(Rc,2));
double e = exp(-pow(R,2)/pow(Rc,2))*P;
P *= exp(-pow(R,2)/pow(Rc,2));
return 0;
}
I'm looking for the value of P. (Above code written for VC++ 6.0.
Library modifications required for the HP.)
On a HP c3750 running aCC: P = -686.71739393609221
On an iMac G5 running Tiger w/gcc: P = -686.71739393609221
On a P3 running ME/ MS VC++ 6.0: P = -686.71739393609209
On the same P3 w/MS VC++ 6.0: b = -686.71739393609221
c = -686.71739393609221
d = -686.71739393609209
e = -686.71739393609209
So my question is why are b and c different than d, e, and P if the
exponent is evaluated before the multiplication? Any comments would be
appreciated. Thanks in advance.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double P = -1943.6650940829325;
double R = 3.6683591763449312;
double Rc = 3.5964170000000002;
double a = exp(-pow(R,2)/pow(Rc,2));
double b = a*P;
double c = P*a;
double d = P*exp(-pow(R,2)/pow(Rc,2));
double e = exp(-pow(R,2)/pow(Rc,2))*P;
P *= exp(-pow(R,2)/pow(Rc,2));
return 0;
}
I'm looking for the value of P. (Above code written for VC++ 6.0.
Library modifications required for the HP.)
On a HP c3750 running aCC: P = -686.71739393609221
On an iMac G5 running Tiger w/gcc: P = -686.71739393609221
On a P3 running ME/ MS VC++ 6.0: P = -686.71739393609209
On the same P3 w/MS VC++ 6.0: b = -686.71739393609221
c = -686.71739393609221
d = -686.71739393609209
e = -686.71739393609209
So my question is why are b and c different than d, e, and P if the
exponent is evaluated before the multiplication? Any comments would be
appreciated. Thanks in advance.