470,848 Members | 1,197 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

finding underflow/overflow threshold for exp(x)

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

Jun 27 '08 #1
0 1277

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

38 posts views Thread by JKop | last post: by
5 posts views Thread by Ian Pilcher | last post: by
13 posts views Thread by tings | last post: by
2 posts views Thread by alok | last post: by
10 posts views Thread by Parachute | last post: by
11 posts views Thread by pereges | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.