finding underflow/overflow threshold for exp(x)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top