What does -1.#IND00 mean??
This is a discussion on -1.#ind00 within the C Programming forums, part of the General Programming Boards category; What does -1.#IND00 mean??...
What does -1.#IND00 mean??
It's Japanese for "I am a very large dinosaur with fourteen eyes"
OK then what does that have to do with the sin() function in math.h? I think that's what's causing the error.
sins are bad, god forgives you if you beg forgivness.
Thanks for the humor. It helps to be able to laugh even though you have 12 hours to finish 4 programs, and you've only had 1 class. UGHHHHH
What is that? is it an error code that's produced or what?
Post some code.....
OK.....
#include <stdio.h>
#include <math.h>
#define PI 3.141592654
double Foward(double x, double h);
double Central(double x, double h);
void main()
{
double x, h, fxF, fxC;
x=1;
h=1/4;
fxF=Foward(x,h);
printf("The value of F prime of 1 using the foward difference formula is %lf \n\n", fxF);
fxC=Central(x,h);
printf("The value of F prime of 1 using the central difference formula is %lf\n\n", fxC);
}
double Foward(double x, double h)
{
double x0, h0, fx, fxh, fprime;
x0=x;
h0=h;
fx=sin(PI*x0);
fxh=sin(PI*(x0+h0));
fprime=(fxh-fx)/h;
return fprime;
}
double Central(double x, double h)
{
double fprime, x0, h0, fxh1, fxh2;
x0=x;
h0=h;
fxh1=sin(PI*(x0+h0));
fxh2=sin(PI*(x0-h0));
fprime=(fxh1-fxh2)/(2*h);
return fprime;
}
This produces
The value of F prime of 1 using the foward difference formula is
-1.#IND00
The value of F prime of 1 using the central difference formula is
-1.#IND00
Any suggestions about the bug?
I have no idea about the bug, but use INT MAIN! (I formatted the code so people who can help have an easier time)
Code:#include <stdio.h> #include <math.h> #define PI 3.141592654 double Foward(double x, double h); double Central(double x, double h); int main(void) { double x, h, fxF, fxC; x=1; h=1/4; fxF=Foward(x,h); printf("The value of F prime of 1 using the foward difference formula is %lf \n\n", fxF); fxC=Central(x,h); printf("The value of F prime of 1 using the central difference formula is %lf\n\n", fxC); return 0; } double Foward(double x, double h) { double x0, h0, fx, fxh, fprime; x0=x; h0=h; fx=sin(PI*x0); fxh=sin(PI*(x0+h0)); fprime=(fxh-fx)/h; return fprime; } double Central(double x, double h) { double fprime, x0, h0, fxh1, fxh2; x0=x; h0=h; fxh1=sin(PI*(x0+h0)); fxh2=sin(PI*(x0-h0)); fprime=(fxh1-fxh2)/(2*h); return fprime; }
Last edited by Brian; 02-18-2002 at 05:52 PM.
I dont know exactly what you are doing, but if you substitute
h=1/4;
for
h=(double)1/4;
...it seems happier....
Still I dont know if the answers given are correct....
OH Yea!!! That actually solved the problem!! Thank you so much.
> h=1/4;
Which would be performed using integer math, giving you the result of 0 (due to truncation), and no doubt the subsequent use of zero was causing grief (perhaps divide by 0)
http://homepages.borland.com/efg2lab...matics/NaN.htm
> What does -1.#IND00 mean??
About the same as #NAN
http://www.cprogramming.com/cboard/s...threadid=11255
I think it means INDefinite (which might also mean denormalised - see the other link)