I've made a question yesterday that got taken as a duplicate, I think by mistake. I need to store 10e-16
in a variable. This alone works, but as soon as I need to subtract it from another double
value, the number doesn't change at all. It only starts working if I change the value from 10e-16
to somothing like 10e-4
. Any lower numbers don't seem to work. I've tried using long double, but to no avail. I don't need cout.precision()
because I don't need to print the number yet, I need it for a loop.
long double x1 = -400, epsilon = 0.000000000000001;
long double x2 = -400 + epsilon;
vector <vector <double> > intervals;
vector <double> interval;
while(x1<=650){
interval.clear();
if(f1(x1)<0){
while(f1(x2) <= 0){
x2 += epsilon;
}
while(f1(x1)<0){
x1 += epsilon;
}
x1 -= epsilon;
interval.push_back(x1);
interval.push_back(x2);
intervals.push_back(interval);
x1=x2;
x2=x1 + epsilon;
}
This is what the loop looks like. The function f1
returns the value of a nonlinear equation. I've tried using GMP, but I've got problems with installing it, which I addressed in a different question. Is there any way to make this work without using GMP?