Hi all,here i have one very simple program.I want to divide an interval [-1,1] into 10 sub intervals.so then i will have each of them devided by 10 more sub sub interval.You can get this from code easy though.What im asking is when its supposed to be zero it gives computer epsilon i.e 3,27826e-8 but it has to be zero.here is my code.what do i need to change this?
output that i have is like this
Code:
interval -1 -0.8
-1 -0.998 -0.996 - 0.994...........................-0.8
....
...
interval -0.2 3,27826e-8
-0.2 -0.198 - 0.196 -0.194.......................3,27826e-8
Code:
#include <iostream>
using namespace std;
int main()
{
float X[11],XSub[11];
int i=0,j=0;
X[0]=-1;
for (i=0;i<10;i++)
{
X[i+1]=X[i]-(- 0.2);
XSub[0]=X[i];
cout<<"interval "<<X[i]<<" "<<X[i+1]<<endl;
for (j=0;j<11;j++)
{
XSub[j+1]=XSub[j]-(-0.02) ;
cout<<XSub[j]<<" ";
}
cout<<endl;
}
cin.get();
return 0;
}