pow function appears to fail randomly.
-
This my program int _tmain(int argc, _TCHAR* argv[]) { int a=0; double b=10; double result = pow(b,a); double r=0; for(int aa=0;aa<30000;aa++) { for(int i=0; i<30000;i++) { for(int j=0; j<30000;j++) { r = pow(b,a); if(r != result) { int error =0; } } } } return 0; } I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848. Could this be a hardware problem or something else? Running VS2008 with latest service packs.
-
This my program int _tmain(int argc, _TCHAR* argv[]) { int a=0; double b=10; double result = pow(b,a); double r=0; for(int aa=0;aa<30000;aa++) { for(int i=0; i<30000;i++) { for(int j=0; j<30000;j++) { r = pow(b,a); if(r != result) { int error =0; } } } } return 0; } I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848. Could this be a hardware problem or something else? Running VS2008 with latest service packs.
-
This my program int _tmain(int argc, _TCHAR* argv[]) { int a=0; double b=10; double result = pow(b,a); double r=0; for(int aa=0;aa<30000;aa++) { for(int i=0; i<30000;i++) { for(int j=0; j<30000;j++) { r = pow(b,a); if(r != result) { int error =0; } } } } return 0; } I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848. Could this be a hardware problem or something else? Running VS2008 with latest service packs.
-
Member 2088 wrote:
I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848.
What were the values of
r
andresult
at the time of failure?When it hit the error line r = -1.#IND000000000000 a and b are correct.
-
When it hit the error line r = -1.#IND000000000000 a and b are correct.
-
Member 2088 wrote:
When it hit the error line r = -1.#IND000000000000 a and b are correct.
So what were the values? Also I asked what the value of
result
was.b=10.000000000000000 a = 0 result = 1.0000000000000000
-
b=10.000000000000000 a = 0 result = 1.0000000000000000
-
This my program int _tmain(int argc, _TCHAR* argv[]) { int a=0; double b=10; double result = pow(b,a); double r=0; for(int aa=0;aa<30000;aa++) { for(int i=0; i<30000;i++) { for(int j=0; j<30000;j++) { r = pow(b,a); if(r != result) { int error =0; } } } } return 0; } I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848. Could this be a hardware problem or something else? Running VS2008 with latest service packs.
Member 2088 wrote:
double b=10; double result = pow(b,a); double r=0;
What happens if you did:
double b = 10.0;
double r = 0.0;"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
-
Is this really the intent of the program, to never change "a" or "b"? because in this case, you'll always get a result of 1. So you'll be going in a double-nested loop for a long time to just get a result of 1...
The point is to demonstrate the 'random' failure.
-
This my program int _tmain(int argc, _TCHAR* argv[]) { int a=0; double b=10; double result = pow(b,a); double r=0; for(int aa=0;aa<30000;aa++) { for(int i=0; i<30000;i++) { for(int j=0; j<30000;j++) { r = pow(b,a); if(r != result) { int error =0; } } } } return 0; } I put a breakpoint on the int error = 0. It got hit when aa=0,i=19383,j= 26848. Could this be a hardware problem or something else? Running VS2008 with latest service packs.
Are you only running the block of code above or is it part of a larger program? Taking over a buggy program in the past, I have had programs that malfunction when a variable name was changed from x to y. This was the result of memory errors that I had to track down and fix.
-
The point is to demonstrate the 'random' failure.