E
er
hi all,
any suggestion for #2?
//#1
struct find_max{
find_max():x(1.0){}
void operator()(){
while(!isinf(exp(2*x))){
x*=2.0;
}
}
double x;
};
#2
struct find_min{
find_min():x(-1.0){}
void operator()(){
while(!isnan(exp(2*x))){//isnan probably not the right
predicate
x*=2.0;
}
}
double x;
};
find_max f; f();
cout << "max=" << f.x << std::endl; //512
find_min g; g();
cout << "min=" << g.x << std::endl; // ...program not terminate
any suggestion for #2?
//#1
struct find_max{
find_max():x(1.0){}
void operator()(){
while(!isinf(exp(2*x))){
x*=2.0;
}
}
double x;
};
#2
struct find_min{
find_min():x(-1.0){}
void operator()(){
while(!isnan(exp(2*x))){//isnan probably not the right
predicate
x*=2.0;
}
}
double x;
};
find_max f; f();
cout << "max=" << f.x << std::endl; //512
find_min g; g();
cout << "min=" << g.x << std::endl; // ...program not terminate